Skip to content

fix: accept batch-only payloads in fetch_node/explore_rpg#92

Open
rrva wants to merge 2 commits into
userFRM:mainfrom
rrva:fix/fetch-node-batch-only-payload
Open

fix: accept batch-only payloads in fetch_node/explore_rpg#92
rrva wants to merge 2 commits into
userFRM:mainfrom
rrva:fix/fetch-node-batch-only-payload

Conversation

@rrva
Copy link
Copy Markdown

@rrva rrva commented May 17, 2026

Summary

fetch_node and explore_rpg advertise a batch mode via entity_ids (an Option<Vec<String>>), and the doc comment on entity_ids says it "overrides entity_id when provided". The handlers in crates/rpg-mcp/src/tools.rs were written for either-or semantics, but serde rejected any call without entity_id because it was declared as a required String.

That made the documented batch-only call shape fail at deserialization with missing field entity_id before 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_node rejected that payload with missing field entity_id before handler code ran. Same failure mode reproduced against explore_rpg with a batch-only payload.

What changed

  • crates/rpg-mcp/src/params.rs: entity_id: String -> entity_id: Option<String> on both FetchNodeParams and ExploreRpgParams. Doc comments now state that either entity_id or entity_ids is required.
  • crates/rpg-mcp/src/tools.rs: fetch_node and explore_rpg now share requested_entity_ids, which preserves the documented precedence (entity_ids overrides entity_id) while validating boundary cases.
  • Missing both fields now returns "either entity_id or entity_ids is required".
  • Explicit empty batches (entity_ids: []) now return "entity_ids must not be empty", including when entity_id is also present.
  • Regression tests cover batch-only deserialization, missing IDs, empty batches, and batch-overrides-single behavior.
  • CHANGELOG.md: new [Unreleased] ### Fixed entry.

Test plan

  • cargo fmt --all -- --check clean
  • cargo clippy --workspace --all-targets -- -D warnings clean
  • cargo test -p rpg-mcp params::tests — 2 passed
  • cargo test -p rpg-mcp requested_entity_ids — 3 passed
  • cargo test --workspace — 656 passed
  • Original batch-only regression tests confirmed failing before the fix and passing after

🤖 Generated with Claude Code

rrva and others added 2 commits May 17, 2026 10:24
`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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] fetch_node and explore_rpg reject batch-only payloads (missing field "entity_id")

1 participant