fix: accept batch-only payloads in fetch_node/explore_rpg#92
Open
rrva wants to merge 2 commits into
Open
Conversation
`fetch_node` and `explore_rpg` advertise a batch mode via `entity_ids`,
with a doc comment stating it "overrides entity_id when provided". The
handlers in `crates/rpg-mcp/src/tools.rs` are written for either-or
semantics — check `entity_ids` first, fall back to `entity_id`. But
serde rejected any call without `entity_id` because the field was
declared `String` (required), so every batch-only call failed at the
deserialization boundary with `missing field 'entity_id'` before the
fallback could run.
Reproduction (verbatim from a failing session):
rpg.fetch_node({
"entity_ids": ["a:main", "a:helper"],
"fields": "source,deps,features"
})
-> Mcp error: -32602: failed to deserialize parameters:
missing field `entity_id`
Fix: `entity_id` is now `Option<String>` on both `FetchNodeParams` and
`ExploreRpgParams`. Both handlers gain a `match` arm that returns
`"either entity_id or entity_ids is required"` when both are absent.
Regression tests added inline in `crates/rpg-mcp/src/params.rs` (matches
the existing `#[cfg(test)] mod tests` convention used in this crate's
`types.rs`, `tools.rs`, `server.rs`, and `helpers.rs`).
The bug has been present since the initial commit (verified via
`git log -S "entity_ids: Option"`); it just hadn't been hit until a
caller used the pure batch form.
Closes userFRM#91
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
fetch_nodeandexplore_rpgadvertise a batch mode viaentity_ids(anOption<Vec<String>>), and the doc comment onentity_idssays it "overrides entity_id when provided". The handlers incrates/rpg-mcp/src/tools.rswere written for either-or semantics, but serde rejected any call withoutentity_idbecause it was declared as a requiredString.That made the documented batch-only call shape fail at deserialization with
missing field entity_idbefore the handlers could run. The failure is deterministic by call shape: single calls worked, calls with both fields worked, and pure batch-only calls failed.Closes #91
Reproduction (before fix)
{ "entity_ids": [ "docker/fetch-runtime-config.mjs:main", "docker/fetch-runtime-config.mjs:fetchSsmEnv", "docker/fetch-runtime-config.mjs:fetchSecrets" ], "fields": "source,deps,features", "source_max_lines": 220 }Before this fix,
fetch_noderejected that payload withmissing field entity_idbefore handler code ran. Same failure mode reproduced againstexplore_rpgwith a batch-only payload.What changed
crates/rpg-mcp/src/params.rs:entity_id: String->entity_id: Option<String>on bothFetchNodeParamsandExploreRpgParams. Doc comments now state that eitherentity_idorentity_idsis required.crates/rpg-mcp/src/tools.rs:fetch_nodeandexplore_rpgnow sharerequested_entity_ids, which preserves the documented precedence (entity_idsoverridesentity_id) while validating boundary cases."either entity_id or entity_ids is required".entity_ids: []) now return"entity_ids must not be empty", including whenentity_idis also present.CHANGELOG.md: new[Unreleased]### Fixedentry.Test plan
cargo fmt --all -- --checkcleancargo clippy --workspace --all-targets -- -D warningscleancargo test -p rpg-mcp params::tests— 2 passedcargo test -p rpg-mcp requested_entity_ids— 3 passedcargo test --workspace— 656 passed🤖 Generated with Claude Code