Skip to content

fix: reject empty JSON-RPC batches - #5

Open
vsolano9 wants to merge 1 commit into
AgentPostmortem:mainfrom
vsolano9:fix-4-empty-json-rpc-batch
Open

fix: reject empty JSON-RPC batches#5
vsolano9 wants to merge 1 commit into
AgentPostmortem:mainfrom
vsolano9:fix-4-empty-json-rpc-batch

Conversation

@vsolano9

Copy link
Copy Markdown

Closes #4

What & why

JSON-RPC 2.0 requires an empty batch to produce one Invalid Request response object. Casebook instead fell through to its response-free batch path and returned HTTP 202.

The guard now rejects [] before dispatch with code -32600 and id: null, matching the official batch specification. Non-empty notification-only batches remain response-free.

Changes

  • reject empty arrays before batch dispatch
  • cover the exact error payload at the HTTP request boundary
  • preserve and cover the notification-only 202 behavior

Validation

  • npm test — 14/14 passed
  • npm run typecheck — passed
  • npx wrangler deploy --dry-run — worker bundle succeeded, no deployment
  • focused batch suite — 20 repeated runs passed

The repository defines no format or lint scripts; git diff --check passes and the two changed files follow the existing style.

Checklist

  • Focused change with a clear description
  • Ran all available validation
  • Docs or CHANGELOG update is not needed for this protocol compliance fix
  • Linked the related issue

AI assistance: Codex helped implement and validate the patch; the final diff and test output were reviewed before submission.

Return the required Invalid Request response before dispatch while preserving response-free notification batches.
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.

Return Invalid Request for an empty JSON-RPC batch

1 participant