You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(responses): reject malformed retained compact input before routing - #8433
Reject malformed OpenCodex retained-compaction (ocx2:) input with HTTP 400 invalid_request_error before routing, account selection, credential refresh or upstream dispatch. Valid envelopes keep their existing send-time expansion. Add pooled-account and no-dispatch regressions, plus the canonical and affected translated compact references.
Carries luvs01/opencodex#813 at 16e55c7df92643fca035437cdbb6186d113a1608, preserving its commit history and authorship.
Verification
Parent head 2a1f907c04f622f2354f8a68010c6fa1bac73f29: Cross-platform CI 42570570874 passed its executed gates, changed-test suite, docs build, API/storage checks and smoke jobs. The full platform matrix was skipped; this is not Windows/macOS acceptance.
The final 16e55c7 commit adds only a five-line JSDoc comment to the compact entrypoint; executable code and tests are unchanged from that passing parent. New-head checks are not yet claimed as passing.
Reviewed the final source diff and prior review fixes, including validation before credential refresh and translated references. No source code was changed for this transfer, so passing unchanged checks were not duplicated locally.
Remains draft pending checks/review in the upstream repository. No merge or deployment is requested by this publication.
Checklist
Scope stays focused and avoids unrelated cleanup.
Docs or release notes were updated when needed.
Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.
Co-authored-by: Epinephrine luvs01@hanmail.net
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Summary by CodeRabbit
Bug Fixes
Malformed retained-compaction input now returns HTTP 400 with an invalid_request_error before routing, credential refresh, or upstream requests.
These validation errors do not trigger upstream retries or affect pooled account health. Valid requests continue to work.
Documentation
Updated the compact-endpoint reference in English, Japanese, Korean, Russian, and Simplified Chinese to describe the error response and validation behavior.
The compact endpoint now rejects malformed proxy-owned ocx2: retained-compaction input with HTTP 400 and invalid_request_error. Validation occurs before routing and credential resolution. Tests cover upstream requests, pooled account health, and credential refresh; the reference documentation describes the behavior in five languages.
Adds a specific error type and a finder for marked retained-compaction items that fail decoding. Expansion uses the shared type guard and throws the specific error for invalid envelopes.
The handler rejects malformed input before the body-read callback and routing, and maps the validation error to HTTP 400. Tests check that invalid input causes no upstream fetch or credential-refresh fetch and does not change pooled account health. The documentation describes the response and validation timing.
lidge-jun/opencodex#8151: Changes how valid retained-compaction envelopes are lowered before native compact requests are sent; this PR adds validation for malformed envelopes.
lidge-jun/opencodex#7774: Changes native-main credential discovery and refresh behavior in the compact path; this PR validates malformed input before credential resolution.
Merge Risk: Minimal · up to 16e55
The reviewed change has no established issue that needs correction before merge. Normal checks remain appropriate for the final commit.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly summarizes the main change: rejecting malformed retained-compaction input before routing.
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 4 files. (5 skipped: 5 unsupported.)
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
src/server/responses/compact.ts-1318-1320: 1
1318-1320: Trivial · Maintainability & Code Quality · Low value
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Remove or justify the unreachable InvalidRetainedCompactionEnvelopeError mapping in localDispatchRefusal.
handleResponsesCompact now rejects malformed envelopes at Line 711, before any send. The only InvalidRetainedCompactionEnvelopeError source in the send path is expandRetainedCompactionInput. buildCompactSendBody does not call that function directly. scrubOcxCompactionItems may call it. Verify whether it can still throw after pre-validation. If it cannot, this branch is dead code. Dead code on a security-adjacent error path invites confusion.
If the branch is a deliberate defense-in-depth measure, add a comment that says so.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Integrate at 16e55c7df92643fca035437cdbb6186d113a1608, subject to an unchanged head and a mergeable PR. This fixes a real user problem: malformed OpenCodex retained-compaction input now gets a useful 400 before routing or credential refresh instead of a late failure that can affect an account. The intended API change applies only to malformed proxy-owned envelopes; valid envelopes retain their existing expansion. There is no GUI or CLI layout change and no settings migration.
Existing users benefit from earlier rejection of requests that could not succeed. The affected code uses JSON and Base64 rather than platform-specific APIs; Windows and macOS were not independently exercised on this head. Documentation and regression coverage accompany the change; structure, file-size, Lab boundary and privacy were reviewed.
A fresh independent reviewer passed this exact head and reported 20 focused tests and 827 broader compaction tests passing, typecheck and repository gates passing, plus a base/head reproduction showing malformed requests no longer refresh credentials or mark an account unhealthy. I independently inspected the diff and verified the exact head and successful gates and test changed in CI run 42575482954. The CI aggregate succeeded. No actual change-caused CI failure was identified.
NOT RUN by maintainer: local tests, full suite, Windows/macOS matrix, live provider request. The reviewer's local commands were not independently rerun. The hosted security reviewer reported a usage limit, not a security approval.
Maintainer integration decision: I intend to integrate under the dev-only maintainer policy if GitHub requires an approval bypass; this does not substitute for the independent review above.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reject malformed OpenCodex retained-compaction (
ocx2:) input with HTTP 400invalid_request_errorbefore routing, account selection, credential refresh or upstream dispatch. Valid envelopes keep their existing send-time expansion. Add pooled-account and no-dispatch regressions, plus the canonical and affected translated compact references.Carries luvs01/opencodex#813 at
16e55c7df92643fca035437cdbb6186d113a1608, preserving its commit history and authorship.Verification
2a1f907c04f622f2354f8a68010c6fa1bac73f29: Cross-platform CI 42570570874 passed its executed gates, changed-test suite, docs build, API/storage checks and smoke jobs. The full platform matrix was skipped; this is not Windows/macOS acceptance.16e55c7commit adds only a five-line JSDoc comment to the compact entrypoint; executable code and tests are unchanged from that passing parent. New-head checks are not yet claimed as passing.Checklist
Co-authored-by: Epinephrine luvs01@hanmail.net
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Summary by CodeRabbit
Bug Fixes
invalid_request_errorbefore routing, credential refresh, or upstream requests.Documentation