fix: compact hwlab web probe script output
This commit is contained in:
@@ -5131,16 +5131,47 @@ function runNodeWebProbeScript(
|
||||
): Record<string, unknown> {
|
||||
const script = nodeWebProbeScriptRemoteShell(options, secretSpec, material.password ?? "");
|
||||
const result = runTransWorkspaceStdinScript(options.node, spec.workspace, script, options.commandTimeoutSeconds);
|
||||
const report = compactWebProbeScriptResult(parseJsonObject(result.stdout));
|
||||
const parsedReport = parseJsonObject(result.stdout);
|
||||
const report = compactWebProbeScriptResult(parsedReport);
|
||||
const passed = result.exitCode === 0 && report?.ok === true;
|
||||
const summary = nullableRecord(report?.summary);
|
||||
const stdoutBytes = Buffer.byteLength(result.stdout, "utf8");
|
||||
const outputFailureKind = parsedReport === null
|
||||
? stdoutBytes > 64 * 1024
|
||||
? "web-probe-output-too-large"
|
||||
: "web-probe-report-parse-failed"
|
||||
: null;
|
||||
const degradedReason = typeof summary?.degradedReason === "string"
|
||||
? summary.degradedReason
|
||||
: typeof report?.failureKind === "string"
|
||||
? report.failureKind
|
||||
: outputFailureKind
|
||||
? outputFailureKind
|
||||
: result.timedOut
|
||||
? "web-probe-command-timeout"
|
||||
: null;
|
||||
const failureKind = typeof summary?.failureKind === "string"
|
||||
? summary.failureKind
|
||||
: typeof report?.failureKind === "string"
|
||||
? report.failureKind
|
||||
: outputFailureKind;
|
||||
const effectiveSummary = summary ?? (outputFailureKind === null ? null : {
|
||||
ok: false,
|
||||
status: "blocked",
|
||||
degradedReason: outputFailureKind,
|
||||
failureKind: outputFailureKind,
|
||||
failedCondition: outputFailureKind === "web-probe-output-too-large"
|
||||
? "remote web-probe stdout exceeded the bounded summary parser input"
|
||||
: "remote web-probe stdout did not contain a parseable JSON report",
|
||||
stdoutBytes,
|
||||
stderrTail: result.stderr.trim().slice(-2000),
|
||||
valuesRedacted: true,
|
||||
});
|
||||
const compactResult = compactCommandResultRedacted(result, [material.password ?? ""]);
|
||||
if (outputFailureKind !== null) {
|
||||
compactResult.stdoutTail = redactKnownSecrets(result.stdout.slice(-2000), [material.password ?? ""]);
|
||||
compactResult.stderrTail = redactKnownSecrets(result.stderr.slice(-2000), [material.password ?? ""]);
|
||||
}
|
||||
return {
|
||||
ok: passed,
|
||||
status: passed ? "pass" : "blocked",
|
||||
@@ -5152,10 +5183,10 @@ function runNodeWebProbeScript(
|
||||
credential,
|
||||
scriptSource: options.scriptSource,
|
||||
degradedReason,
|
||||
failureKind: typeof summary?.failureKind === "string" ? summary.failureKind : typeof report?.failureKind === "string" ? report.failureKind : null,
|
||||
summary,
|
||||
failureKind,
|
||||
summary: effectiveSummary,
|
||||
probe: report,
|
||||
result: compactCommandResultRedacted(result, [material.password ?? ""]),
|
||||
result: compactResult,
|
||||
valuesRedacted: true,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user