fix: decode a GetSessionPolicy error reply as Err, not an empty policy - #1055
Conversation
`min session policy` reported no restrictions with exit 0 for nonexistent, destroyed, or mistyped sessions: a silent false negative on a security-introspection command. The daemon replies with an error object, but the client wire type Errorable<SessionPolicy> is #[serde(untagged)] and every SessionPolicy field is Option, so that error decoded as a valid empty Ok policy instead of the Err arm. Add #[serde(deny_unknown_fields)] to SessionPolicy so the untagged decoder rejects the error key on the Ok arm and falls through to Err. Serialization is unchanged; a regression test is added in minimald-rpc. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 14 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?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 reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Comment |
Fixes #1025
Routing-Key: inbox-route/I_kwDOSUhdos8AAAABKmgZqg
min session policyreturned an all-null policy with exit 0 for nonexistent, destroyed, or mistyped sessions — a silent false negative on a security-introspection command. The daemon replies{"error":"no session found"}, but the client wire typeErrorable<SessionPolicy>is#[serde(untagged)]and everySessionPolicyfield isOption, so the error object decoded as a validOk(SessionPolicy { egress: None, ingress: None }). The fix adds#[serde(deny_unknown_fields)]toSessionPolicyso the untagged decoder rejects theerrorkey on theOkarm and falls through toErr; wire serialization is unchanged. TheGetSessionPolicy/Errorablecontract this touches was introduced by minimal#521 (informed by #521). A regression test inminimald-rpcpins both directions.Verification
cargo fmt --all --check — pass, no drift
cargo clippy --workspace --locked -- -D warnings — pass, 0 warnings (finished in 8m 19s)
cargo build --workspace --locked — pass (finished in 3m 47s)
cargo test --workspace --locked — pass; minimald-rpc 17 passed / 0 failed, incl. errorable_session_policy_decodes_daemon_error_as_err
Note
Fix
GetSessionPolicyerror replies decoding as empty policy instead ofErrAdds
#[serde(deny_unknown_fields)]toSessionPolicyin sessions/src/lib.rs so thatErrorable<SessionPolicy>(untagged enum) no longer accepts{"error":"..."}as a valid empty policy — it now correctly matches theErrarm. A regression test in minimald-rpc/src/lib.rs verifies both the error and valid-policy decode paths.Behavioral Change: any
SessionPolicyJSON with fields other thanegressandingressnow fails deserialization; previously unknown fields were silently ignored.Macroscope summarized 0b344d7.