Repository navigation
Preserve CLI proxy timeout diagnostics when logs exceed the capture limit - #76538
Conversation
…tic tails Co-authored-by: pelikhan <[email protected]>
Co-authored-by: pelikhan <[email protected]>
|
✅ Ponytail Reviewer completed successfully!
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Code Quality Reviewer completed the code quality review. PR Code Quality ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ PR Specification Reviewer completed successfully!
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
There was a problem hiding this comment.
What this change does: It retains a bounded, redacted tail of CLI proxy diagnostics and reports startup failures directly.
One simplification: remove the file-input mode now that production uses stream capture, and move its relevant tests to the capture path.
Verdict: Ship.
Lean: -15 lines possible.
Generated by ✂️ Ponytail Reviewer for #76538 · codex · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ⊞ 181
Comment /ponytail to run again
| const content = readCliProxyDiagnostics(process.argv[2]); | ||
| const redacted = redactCliProxyDiagnostics(content, process.env); | ||
| process.stdout.write(redacted.trimEnd().split("\n").slice(-20).join("\n")); | ||
| const captured = process.argv[2] === "--capture" ? await captureCliProxyDiagnostics(process.stdin) : null; |
There was a problem hiding this comment.
The only production caller now uses --capture, so the file-input branch and readCliProxyDiagnostics are used only by tests. Remove that mode and move the relevant output tests to capture; this removes a second input path and its file-only tests without changing the proxy or gateway callers.
There was a problem hiding this comment.
Addressed in e585ddf: removed the file-input branch and readCliProxyDiagnostics, migrated output coverage to stream capture, and removed file-only tests. The gateway’s shared redaction API is unchanged.
There was a problem hiding this comment.
Reviewed PR head 2e5e2768b180e8a6d6ddab47c13bde388d893030 against specs/compiler-threat-detection-spec.md §5.2.2 (Proxy Startup Diagnostic Privacy).
Blocking finding: the new capture path publishes a bounded/truncated tail on overflow, whereas the existing MUST contract requires withholding the entire captured payload and emitting only a fixed, value-free error; partially sanitized or truncated raw output MUST NOT be published. Inline comment added on actions/setup/sh/start_cli_proxy.sh:77. No specification synchronization is eligible because the implementation change conflicts with the mandatory security contract.
Generated by PR Specification Reviewer for #76538 · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review-specs to run again
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Found two low-severity issues: the capture loop copies the retained 1 MiB tail on every chunk, causing avoidable O(log_size × 1 MiB) copying for oversized logs; and sanitizer-failure tests were weakened from exact-output checks to substring checks, allowing partial diagnostic leakage to pass. No blocking correctness issue identified in the static review. Tests were not run per review constraints.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~7 AIC · ⌖ ~2 AIC · ⊞ 1.6K
Comment /review to run again
| const result = runProxy({ ready, sanitizerFailure: true }); | ||
| expect(result.status).toBe(1); | ||
| expect(result.output).toBe("::error::CLI proxy diagnostics withheld because secret redaction failed\n"); | ||
| expect(result.output).toContain("::error::CLI proxy diagnostics withheld because secret redaction failed\n"); |
There was a problem hiding this comment.
These assertions no longer guarantee the fail-closed output is the only published output. A regression could emit partial sanitizer content and still satisfy toContain. Please assert exact stdout (or explicitly assert that no diagnostic payload is present) for both sanitizer-failure cases.
There was a problem hiding this comment.
Addressed in e585ddf: sanitizer-failure tests now assert empty stdout and exact stderr, including the separately emitted timeout message where applicable. Partial diagnostic output fails these assertions.
| const text = chunk.toString().replaceAll("\0", ""); | ||
| const bytes = Buffer.from(text); | ||
| truncated ||= tail.length + bytes.length > MAX_DIAGNOSTIC_BYTES; | ||
| tail = Buffer.concat([tail, bytes]).subarray(-MAX_DIAGNOSTIC_BYTES); |
There was a problem hiding this comment.
This rebuilds and copies up to the full 1 MiB retained tail for every stdin chunk. On a large Docker log, that makes capture cost grow roughly as O(log_size × 1 MiB), adding substantial CPU and memory bandwidth precisely on the overflow path. Please use a bounded chunk/ring-buffer approach or trim only when the retained buffer exceeds a larger threshold.
There was a problem hiding this comment.
Addressed in e585ddf: capture stores bounded chunks and concatenates only once. On overflow it discards all stored chunks and drains remaining input without copying a retained tail.
There was a problem hiding this comment.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~12 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
| } | ||
| collectMasks(pending); | ||
| // Never publish the first partial line: truncation could split a credential. | ||
| const content = truncated ? tail.subarray(tail.indexOf(10) + 1).toString("utf8") : tail.toString("utf8"); |
There was a problem hiding this comment.
[/diagnosing-bugs] When the tail has no newline, indexOf(10) + 1 evaluates to 0, so the slice keeps the whole buffer. Line 96 is the only guard that stops a partial line from being published. This invariant is subtle and easy to break in a refactor.
💡 Suggested change
Add a one-line comment explaining that the empty-string guard on line 96 is what prevents publishing a truncated first line. Add a direct unit test for a truncated tail that contains no newline.
@copilot please address this.
There was a problem hiding this comment.
Addressed in e585ddf: restoring fail-closed overflow removes the partial-line slicing invariant entirely. A comment explains that unterminated partial lines are also withheld, and the direct no-newline overflow test asserts both streams are empty.
| const result = runProxy({ ready, sanitizerFailure: true }); | ||
| expect(result.status).toBe(1); | ||
| expect(result.output).toBe("::error::CLI proxy diagnostics withheld because secret redaction failed\n"); | ||
| expect(result.output).toContain("::error::CLI proxy diagnostics withheld because secret redaction failed\n"); |
There was a problem hiding this comment.
[/tdd] This exact toBe assertion on withheld output was changed to toContain, so the test no longer proves that nothing else reaches the output. Restore an exact check on the withheld stdout, or assert the full output matches the expected diagnostic lines.
💡 Suggested assertion
Assert the complete result.output against the expected withheld message, so any extra leaked line fails the test.
@copilot please address this.
There was a problem hiding this comment.
Addressed in e585ddf: replaced substring checks with exact empty-stdout and full-stderr assertions for sanitizer execution failure, thrown redactor exceptions, and missing sanitizer cases.
There was a problem hiding this comment.
🟡 Changes recommended
Redaction ordering and byte-boundary handling can discard useful diagnostics or complete retained lines, leaving logs empty.
3 open issues
What changed in this PR
This PR addresses #76449 by keeping CLI proxy startup failure messages visible when logs exceed the capture limit, while preserving a bounded, redacted diagnostic tail.
Changes:
- Reports timeout and upstream-connectivity failures independently of log capture.
- Adds streaming tail capture with bounded mask metadata and fail-closed redaction.
- Extends tests for oversized logs, successful startup, partial lines, and mask limits.
| File | Description |
|---|---|
actions/setup/sh/start_cli_proxy.sh |
Separates failure reporting from capture and publishes sanitized tails with truncation warnings. |
actions/setup/js/start_cli_proxy.test.cjs |
Checks failure messages, bounded diagnostics, and successful startup despite oversized output. |
actions/setup/js/redact_cli_proxy_diagnostics.test.cjs |
Adds capture tests for mask retention, partial-line removal, and metadata limits. |
actions/setup/js/redact_cli_proxy_diagnostics.cjs |
Implements bounded streaming capture, full-stream mask collection, and output-size enforcement. |
Review effort: Max (auto)
| tail = Buffer.concat([tail, bytes]).subarray(-MAX_DIAGNOSTIC_BYTES); | ||
| const lines = (pending + text).split("\n"); | ||
| pending = lines.pop() || ""; | ||
| for (const line of lines) collectMasks(line); | ||
| // Keep scanning giant lines for commands without retaining their full prefix. | ||
| const command = pending.indexOf("::add-mask::"); | ||
| if (command !== -1) pending = pending.slice(command); | ||
| if (Buffer.byteLength(pending) > MAX_DIAGNOSTIC_BYTES) { | ||
| if (command !== -1) throw new Error("CLI proxy mask limit exceeded"); | ||
| pending = Buffer.from(pending).subarray(-MAX_DIAGNOSTIC_BYTES).toString("utf8"); | ||
| } | ||
| } | ||
| collectMasks(pending); | ||
| // Never publish the first partial line: truncation could split a credential. | ||
| const content = truncated ? tail.subarray(tail.indexOf(10) + 1).toString("utf8") : tail.toString("utf8"); | ||
| return { content: truncated && !tail.includes(10) ? "" : content, truncated, masks: [...masks] }; |
| const redacted = redactCliProxyDiagnostics(content, process.env); | ||
| process.stdout.write(redacted.trimEnd().split("\n").slice(-20).join("\n")); | ||
| const captured = process.argv[2] === "--capture" ? await captureCliProxyDiagnostics(process.stdin) : null; | ||
| const content = captured ? captured.content.trimEnd().split("\n").slice(-20).join("\n") : readCliProxyDiagnostics(process.argv[2]); |
| const tail = Buffer.from(output).subarray(-MAX_DIAGNOSTIC_BYTES); | ||
| output = tail.includes(10) ? tail.subarray(tail.indexOf(10) + 1).toString("utf8") : ""; |
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "2e5e2768b180e8a6d6ddab47c13bde388d893030",
"kind": "requested",
"schema_version": "1",
"state": "2e56f8aac1536dc65ed8beab140448e346b1104cee79b12311fe3b5d29631475",
"work": [
"5371a7c744076eaa4ea7ea1b61bc447a45468d7b4ba16851a304d2c87b2e8780",
"66dd2306415ecb7c578e7e47a41c1f8adf7a3f1f868fa7634e96b6cfd7010a64",
"8166fc635be3561e78f601b760a3dd0de11658c0575faf0f62f55995440a7b9a",
"8735b77ff9fcbe649e584627ec82a9938cd5055ac7c90a06d600572234e8ddb4",
"c949b77c6058eaf5000a0ded8d45f7b01eb267eb6e754e93ea89b516669e22f7",
"f4144ba94041362ebd70aa4b5e8fac9be87d303b0fbda438aba7fcc3bb98b8a2"
],
"workflow": "pr-sous-chef"
}
|
…imeout-diagnostics Co-authored-by: gh-aw-bot <[email protected]>
Co-authored-by: gh-aw-bot <[email protected]>
Updated from main using make merge-main (merge commit 7bc4a4f) and addressed all six linked requests in e585ddf. Overflow now withholds the entire payload per the privacy contract while preserving separately emitted startup failure reasons; unused file mode and repeated tail copying are removed, with exact leakage assertions restored. Build and all 365 workflow compilations passed; focused proxy/gateway tests passed (282 passed, 1 skipped), the final validation gate passed, and secret scanning found no secrets. CodeQL timed out and instructed against retrying, so that check remains incomplete. No PR merge or CI dispatch was performed. |
|
@copilot ensure this change is privacy preserving, no secrets are leaked |
Reviewed the capture/publish path: raw diagnostics are processed in memory and only the redacted result can reach the private temporary capture file. Overflow and redaction failures publish no diagnostic payload and emit only fixed, value-free errors. The tests assert empty output on these failure paths and verify GH_TOKEN, registered masks, proxy variables, and built-in token patterns are redacted. Focused tests pass (57/57), and the branch’s impacted-js-tests CI job passed. No further code change was needed. |
|
🎉 This pull request is included in a new release. Release: |

CLI proxy logs exceeding the capture limit suppressed both the startup failure reason and all captured diagnostics. This change separates failure reporting from capture and retains a bounded, redacted log tail.