fix(desktop): bound problem report size with per-component byte budgets#1471
Conversation
|
Warning Review limit reached
More reviews will be available in 12 minutes and 56 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The 5 MB overall truncation ladder was the only size bound, so a single large source (a multi-MB log, a long session) could fill the whole report and crowd out everything else while still passing under the total limit. Add a per-component budget pass that runs after redaction and before the overall ladder, bounding each source independently: - log tail capped to its own budget, keeping the most recent lines - session messages dropped oldest-first to a total budget - renderer error details capped to a head budget (keeps the message + top of the stack) The overall maxBytes ladder is now the fallback, not the primary bound. A new truncation.omittedRendererErrorBytes field keeps the ledger honest. Also bound collection and widen the incident window: - tailFile reads only the last 512 KB of each log via a bounded fd read instead of loading the whole file, and caps any single pathological line - renderer diagnostics slice widens its fixed 5-minute lookback (a manual trigger usually happens after the problem); when scoped by session/trace it goes wider still, with capEvents/maxBytes bounding the bytes Refs #1465 Claude-Session: https://claude.ai/code/session_011KyY9wTxQu9oZLy4yPEi3W
ed0094e to
c7e3266
Compare
- capMessageParts: keep the LATEST parts when trimming an oversized message (the tool output / error nearest the failure), matching the rest of the ladder which drops oldest-first, instead of keeping the start of the turn. - Drop the test-only `Options.budgets` override: budgets are fixed and not a public API. Make COMPONENT_BUDGETS private and export the pure cap helpers (headBytes / capLogTailBytes / capMessageParts / capSessionMessagesBytes) so their small-limit edge cases are tested directly instead of via a production override. - Bound scoped (session/trace) renderer slices to the same default 30-min lookback as unscoped slices; an explicit `from` widens the window. Removes the unbounded NEGATIVE_INFINITY lower bound so a manual trigger collects minimally by default.
There was a problem hiding this comment.
Suggested priority: P2 (includes user-path files (packages/desktop-electron/src/main/logging.test.ts, packages/desktop-electron/src/main/logging.ts, packages/desktop-electron/src/main/problem-report-redact.test.ts, packages/desktop-electron/src/main/problem-report-redact.ts, packages/desktop-electron/src/main/problem-report.test.ts, packages/desktop-electron/src/main/problem-report.ts, packages/desktop-electron/src/main/renderer-diagnostics-slice.test.ts, packages/desktop-electron/src/main/renderer-diagnostics-slice.ts)).
P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.
|
Addressed the review in place (no split) — pushed as Changes
On splitting out the private-key redactor (P3)Kept as one PR. The private-key body-matching logic lives in Verification |
…Events Renderer diagnostics were byte-capped only at the source (when the slice is built). buildProblemReport then redacts them, which can re-expand the slice, but they were not re-bounded by the component-budget pass — and the overall fallback ladder used a bespoke event-drop loop that broke on the first protected (incident / identity-transition) event, leaving an all-protected oversized slice unbounded (it could overflow maxBytes and throw). - Add rendererDiagnosticsBytes (= SESSION_EXPORT_RENDERER_DIAGNOSTICS_MAX_BYTES) to the fixed component budgets. - Re-bound the slice post-redaction with the same capEvents() ruler used at the source, re-derived from an immutable redacted baseline so the omitted ledger stays correct across the component pass and the overall ladder. - Replace the bespoke fallback loop with a capEvents-based shrink that can drop even incident events once a tight maxBytes leaves no alternative, so the slice drains to empty rather than overflowing. Removes the now-unused isProtectedRendererDiagnosticEvent duplicate predicate. - Tests: all-protected oversized slice drains under a tight maxBytes (no throw); oversized events are re-bounded to the component budget below the overall limit.
|
Addressed both items — pushed as P2 — renderer diagnostics re-budgeted after redaction (implemented)Verified the gap: the slice is byte-capped only at the source; Fix, with
P3 — PR description aligned to current head (done)Rewrote the description: removed Verification |
Summary
Bound the "Prepare Diagnostics Package" export with per-component byte budgets — PR2 of the diagnostics-package rebuild (#1465). Each component is capped to its own budget after redaction and before the overall 5 MB truncation ladder (which becomes a fallback):
logTailBytes1 MB,sessionMessagesBytes1 MB,sessionMessageBytes256 KB,rendererErrorDetailsBytes64 KB (bounds both the renderer-error summary and details),rendererDiagnosticsBytes1 MB. The cap helpers (capLogTailBytes/capMessageParts/capSessionMessagesBytes/headBytes/capEvents) are exported and unit-tested directly at small limits, with a few default-budget tests covering the end-to-end wiring.capSessionMessagesBytesdrops even the newest message if it does not fit, so the cap is a true ceiling;capMessagePartskeeps the latest parts of an oversized turn (the tool output / error nearest the failure), matching the ladder's oldest-first drop order.capEvents()ruler. The component pass and the overall fallback share that one mechanism (incident events dropped only when a tight limit leaves no alternative), replacing a divergent bespoke fallback loop that could leave an all-protected oversized slice unbounded.headBytes/tailBytes) so capping never splits a multi-byte codepoint at the budget boundary.isTruncation.problem-report-redact.ts): defense moved out of the truncation layer into the redactor as anchored, linear-time (ReDoS-safe) rules covering completeBEGIN..ENDblocks,BEGIN-truncated keys, markerless ≥2-line base64 bodies, orphanedENDmarkers (separate line, same line, PGP=CRCchecksum line), armor-headered bodies, and CRLF.Why
The export could grow without bound: a single huge log tail, one giant session message, or an oversized renderer-error blob could dominate the report or trip the overall 5 MB cap in a way that silently drops other components. Per-component budgets make each part's ceiling explicit and keep the report balanced, with the overall ladder only as a fallback. The budget/truncation work also surfaced a real redaction gap: a pre-redaction tail cut could strand a private-key body whose
BEGINmarker was removed, defeating aBEGIN-keyed redactor — so private-key defense now lives entirely in the redactor.Related Issue
Refs #1465 (umbrella). This is PR2; PR1 #1470 is merged, PR3 #1472 follows. Rebased flat onto
devafter #1470 merged.Human Review Status
PendingReview Focus
tailFile(byte + line tail of the log), which now only drops a partial first line — multi-line-secret defense lives entirely in the redactor.capEvents()ruler in both the component pass and the overall fallback (re-derived from the redacted baseline so the omitted ledger stays correct), instead of a separate fallback loop that broke on protected events.Risk Notes
Accepted residuals (confirmed by an independent adversarial review; left as documented tradeoffs rather than risking the ReDoS-safety / false-positive balance):
BEGINmarker was truncated away keeps the same{16,}per-line floor used everywhere else (the floor avoids redacting legitimate short base64 tokens/hashes). Real tools emit 64–76 char lines, so this only affects deliberately re-wrapped keys. PR3's human-review step is the backstop.slice()for log / renderer-error text. It is effectively unreachable under default budgets (component budgets sum well under 5 MB), so a lone-surrogate split there is cosmetic.How To Verify
Screenshots or Recordings
None — no visible UI in this PR (the in-app review panel is PR3 #1472).
Checklist
bug,enhancement,task,documentation. Type labels are author-added; the labeler bot does NOT assign them. Add the label in the GitHub UI, then tick this.app,ui,platform,harness,ci. The labeler bot assigns these on PR open based on changed paths. Confirm the bot's choice (or override if wrong), then tick this.P0,P1,P2,P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.Pending,Approved by @<reviewer>, orNot required: <reason>(default isPending; "not required" is restricted to bot-authored low-risk PRs).dev, and my PR title and commit messages use Conventional Commits in English.