@@ -2,6 +2,7 @@
|
2 | 2 | import fs from "node:fs/promises"; |
3 | 3 | import path from "node:path"; |
4 | 4 | import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; |
| 5 | +import { parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime"; |
5 | 6 | import { uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime"; |
6 | 7 | import { |
7 | 8 | buildQaAgenticParityComparison, |
@@ -90,6 +91,8 @@ import {
|
90 | 91 | } from "./tool-coverage-report.js"; |
91 | 92 | |
92 | 93 | const QA_SUITE_INFRA_RETRY_LIMIT = 1; |
| 94 | +const QA_CREDENTIAL_PAYLOAD_MAX_BYTES_ENV = "OPENCLAW_QA_CREDENTIAL_PAYLOAD_MAX_BYTES"; |
| 95 | +const DEFAULT_QA_CREDENTIAL_PAYLOAD_MAX_BYTES = 64 * 1024 * 1024; |
93 | 96 | const QA_SUITE_INFRA_RETRY_NETWORK_ERROR_CODES = new Set([ |
94 | 97 | "ECONNRESET", |
95 | 98 | "ECONNREFUSED", |
@@ -543,7 +546,29 @@ async function runInterruptibleServer(label: string, server: InterruptibleServer
|
543 | 546 | await new Promise(() => {}); |
544 | 547 | } |
545 | 548 | |
| 549 | +function resolveQaCredentialPayloadFileMaxBytes(env: NodeJS.ProcessEnv = process.env) { |
| 550 | +const raw = env[QA_CREDENTIAL_PAYLOAD_MAX_BYTES_ENV]?.trim(); |
| 551 | +if (!raw) { |
| 552 | +return DEFAULT_QA_CREDENTIAL_PAYLOAD_MAX_BYTES; |
| 553 | +} |
| 554 | +const parsed = parseStrictPositiveInteger(raw); |
| 555 | +if (parsed === undefined) { |
| 556 | +throw new Error(`${QA_CREDENTIAL_PAYLOAD_MAX_BYTES_ENV} must be a positive integer.`); |
| 557 | +} |
| 558 | +return parsed; |
| 559 | +} |
| 560 | + |
546 | 561 | async function readQaCredentialPayloadFile(filePath: string) { |
| 562 | +const maxBytes = resolveQaCredentialPayloadFileMaxBytes(); |
| 563 | +const stat = await fs.stat(filePath); |
| 564 | +if (!stat.isFile()) { |
| 565 | +throw new Error("Payload file must be a regular JSON file."); |
| 566 | +} |
| 567 | +if (stat.size > maxBytes) { |
| 568 | +throw new Error( |
| 569 | +`Payload file exceeds ${QA_CREDENTIAL_PAYLOAD_MAX_BYTES_ENV} (${maxBytes} bytes).`, |
| 570 | +); |
| 571 | +} |
547 | 572 | const text = await fs.readFile(filePath, "utf8"); |
548 | 573 | let payload: unknown; |
549 | 574 | try { |
|