fix(management): harden native toggle request handling - #1264
Conversation
📝 WalkthroughWalkthroughNative integration toggle routes now reject null, array, and primitive request bodies. Claude toggle persistence now restores the prior in-memory state when saving fails. Tests cover validation, state preservation, and retry behavior. ChangesNative toggle integrity
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
|
✅ Deterministic PR hygiene checks passed. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Ingwannu
left a comment
There was a problem hiding this comment.
Reviewed exact head c85d792d. The route now rejects null/non-object/array JSON before reading enabled, preserving the existing 400 contract instead of throwing. Focused coverage passed locally (11 tests), git diff --check passed, and typecheck passed. The substantive cross-platform shards, gates, privacy scan, keyring jobs, and platform tests are green; the macOS npm-global packaging job is still waiting for a runner, so do not merge until that final job completes successfully.
c85d792 to
a1cf0d9
Compare
Ingwannu
left a comment
There was a problem hiding this comment.
Re-reviewed rebased exact head a1cf0d9c. The PR diff is byte-equivalent in scope to the previously approved patch and still contains only the null-body guard plus its regression. Exact-head focused tests passed 11/11 and typecheck passed. Do not merge until the newly triggered exact-head CI is green.
a1cf0d9 to
a9dc822
Compare
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. This PR stays in draft until every box above is ticked. |
|
Updated exact head The original null-body fix remains, and review of the surrounding route found two additional issues that are now covered in the same focused native-toggle patch:
Verification at the published tree:
Fresh exact-head CI runs are awaiting maintainer approval, and the PR remains Draft pending CI and a new exact-head review. |
Rebase the native-toggle validation fix onto current dev, reject non-object bodies across sibling routes, and restore the live Claude snapshot when persistence fails so the same object can retry safely.
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Approved the pending Cross-platform CI run at this exact head, and it came back green. Worth explaining the silence beforehand: contributor PRs queue their workflow runs as To be precise about what this does and does not do: it only unblocks CI. It does not make this mergeable. The four-box readiness checklist in the description is your attestation, and the gate keeps the PR in draft until you complete it. With CI now green at your head, box 1 is provable. If anything in the run looks wrong to you, say so and I will dig into it rather than leaving you to guess. |
|
Landed on Independent security review passed clean. Verified Thanks — extending the guard to the sibling routes rather than patching only the reported one was the right instinct. |
Summary
null, arrays, and other non-object JSON bodies across the Claude, Codex, Grok, and Claude Desktop native-toggle routes;enabledfield through one shared type guard before any desired-state or artifact mutation;Why
The original Claude route parsed JSON into an object-shaped TypeScript variable and immediately read
body.enabled. JSONnulltherefore bypassed malformed-JSON handling and raised a TypeError. The same runtime assumption remained in the Codex, Grok, and Claude Desktop sibling routes.A deeper review found a second Claude-specific failure mode. The route changed
config.claudeCodebefore calling the persistence seam. If the config lock returned 409/500, the live object stayed changed even though disk did not. Retrying with that same server snapshot then hit the “already current” branch and skipped persistence entirely.The shared guard now rejects non-object bodies before every native-toggle mutation. Claude persistence remains the commit point: any thrown save restores the exact prior property state before returning or rethrowing.
Verification
b22e0e6d0): the same four suites 51/51 passed.bun x tsc --noEmit: passed.bun scripts/privacy-scan.ts: passed.git diff --check: passed.--isolateinternal assertion while entering the storage-policy tests; no test failure was reported before the runtime crash.Checklist
Draft pending exact-head upstream CI and fresh maintainer review.
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit