Deny unknown fields on RPC Request and Response#6926
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (3)
WalkthroughThis PR extends FOREST_STRICT_JSON strict validation to reject unknown fields for RPC request parameters and RPC response results. It adds a serde_ignored-based deserialization helper and replaces direct Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Reflect
participant Parser
participant Validator
Client->>Reflect: send JSON-RPC request
Reflect->>Parser: extract params (serde_json::Value)
Parser->>Validator: from_value_rejecting_unknown_fields(params)
Validator-->>Parser: Ok(T) / Err(unknown fields error)
Parser-->>Reflect: deserialized params / propagate error
Reflect->>Client: invoke method or return parse error
Note over Validator,Parser: For responses, Reflect also calls Validator to deserialize results before returning to client
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CHANGELOG.md`:
- Line 32: Update the CHANGELOG entry that currently references the PR number
[`#6926`] to reference the tracked issue numbers instead; replace the PR link and
label with the issue reference(s) [`#5600`] and/or [`#5635`] and the corresponding
issue URL(s) while keeping the rest of the description unchanged ("Added strict
JSON validation to deny unknown fields in RPC request parameters and response
results when `FOREST_STRICT_JSON` is enabled."); edit the exact line that
contains the current "- [`#6926`](...): ..." entry so the format matches other
changelog entries (use [`#ISSUE_NO`](link-to-issue): <description>).
In `@src/rpc/reflect/mod.rs`:
- Around line 278-285: The current validation only re-serializes Forest's own
LotusJson before returning; to actually reject unknown fields from remote nodes
update RpcMethodExt::call_raw to validate the incoming JSON payload using
crate::rpc::json_validator::from_value_rejecting_unknown_fields (into the
<Self::Ok as HasLotusJson>::LotusJson type) instead of using plain
serde_json::from_value, so the client.call(...) result is passed through
from_value_rejecting_unknown_fields (honoring FOREST_STRICT_JSON behavior) and
any unknown fields cause an error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9e9c365b-6589-49ef-96e3-d17f624df0ce
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
CHANGELOG.mdCargo.tomldocs/docs/users/reference/env_variables.mdsrc/rpc/json_validator.rssrc/rpc/reflect/mod.rssrc/rpc/reflect/parser.rs
40f2c4d to
d12342e
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 6 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Summary of changes
Changes introduced in this pull request:
FOREST_STRICT_JSONis enabled.FOREST_STRICT_JSONto be enabled for api compare test in a follow up PR.Reference issue to close (if applicable)
Closes #5600
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit
New Features
Documentation
Tests