fix: read async web probe reports from file

This commit is contained in:
Codex
2026-06-18 03:36:53 +00:00
parent 3da4533300
commit 4c844da11c
+39 -3
View File
@@ -5149,7 +5149,12 @@ function runNodeWebProbeAsync(
};
}
const poll = pollNodeWebProbeJob(options, spec, jobId);
const report = record(record(poll.status).report);
const statusReport = record(record(poll.status).report);
const reportPath = typeof start.reportPath === "string" ? start.reportPath : null;
const reportLoad = Object.keys(statusReport).length > 0
? { source: "status", report: statusReport, result: null as CommandResult | null, degradedReason: null as string | null, path: null as string | null }
: readNodeWebProbeReport(options, spec, reportPath);
const report = reportLoad.report ?? {};
const probe = compactWebProbeResult(Object.keys(report).length > 0 ? report : null);
const passed = probe?.status === "pass";
const summary = nullableRecord(probe?.summary);
@@ -5158,8 +5163,8 @@ function runNodeWebProbeAsync(
: typeof probe?.degradedReason === "string"
? probe.degradedReason
: poll.status === null
? "web-probe-async-status-failed"
: null;
? reportLoad.degradedReason ?? "web-probe-async-status-failed"
: reportLoad.degradedReason;
return {
ok: passed,
status: passed ? "pass" : "blocked",
@@ -5191,10 +5196,39 @@ function runNodeWebProbeAsync(
screenshotPath: start.screenshotPath ?? null,
},
statusResult: poll.result === null ? null : compactCommandResult(poll.result),
reportLoad: {
source: reportLoad.source,
path: reportLoad.path,
result: reportLoad.result === null ? null : compactCommandResult(reportLoad.result),
degradedReason: reportLoad.degradedReason,
},
valuesRedacted: true,
};
}
function readNodeWebProbeReport(
options: NodeWebProbeRunOptions,
spec: HwlabRuntimeLaneSpec,
reportPath: string | null,
): { source: string; report: Record<string, unknown> | null; result: CommandResult | null; degradedReason: string | null; path: string | null } {
if (!reportPath) return { source: "missing", report: null, result: null, degradedReason: "web-probe-report-path-missing", path: null };
if (!isSafeWebProbeReportPath(reportPath)) return { source: "unsafe-path", report: null, result: null, degradedReason: "web-probe-report-path-invalid", path: reportPath };
const result = runTransWorkspaceStdinScript(options.node, spec.workspace, `cat ${shellQuote(reportPath)}`, 55);
if (result.exitCode !== 0 || result.timedOut) return { source: "report-file", report: null, result, degradedReason: result.timedOut ? "web-probe-command-timeout" : "web-probe-report-read-failed", path: reportPath };
const report = parseJsonObject(result.stdout);
return {
source: "report-file",
report,
result,
degradedReason: report === null ? "web-probe-report-parse-failed" : null,
path: reportPath,
};
}
function isSafeWebProbeReportPath(reportPath: string): boolean {
return reportPath.includes("/.state/web-live-dom-probe/") && reportPath.endsWith(".result.json") && !reportPath.includes("\0");
}
function pollNodeWebProbeJob(options: NodeWebProbeRunOptions, spec: HwlabRuntimeLaneSpec, jobId: string): {
status: Record<string, unknown> | null;
result: CommandResult | null;
@@ -10065,6 +10099,8 @@ function compactWebProbeTraceSamples(value: unknown): Record<string, unknown>[]
rowCount: sample.rowCount ?? null,
emptyLabel: sample.emptyLabel ?? null,
latestRowPreview: sample.latestRowPreview ?? null,
userVisibleRowCount: sample.userVisibleRowCount ?? null,
latestUserVisibleRowPreview: sample.latestUserVisibleRowPreview ?? null,
conversationId: sample.conversationId ?? null,
sessionId: sample.sessionId ?? null,
traceId: sample.traceId ?? null,