Skip to content

fix: standardize resource not found error code - #1037

Closed
CrypticCortex wants to merge 1 commit into
modelcontextprotocol:mainfrom
CrypticCortex:fix/resource-not-found-error-code
Closed

CrypticCortex wants to merge 1 commit into
modelcontextprotocol:mainfrom
CrypticCortex:fix/resource-not-found-error-code

Conversation

@CrypticCortex

@CrypticCortex CrypticCortex commented Jun 24, 2026 •

Copy link
Copy Markdown

Summary

  • Align McpError.RESOURCE_NOT_FOUND with SEP-2164 by using JSON-RPC INVALID_PARAMS (-32602).
  • Update the resource-not-found error code regression expectation.

Test plan

  • ./mvnw -pl mcp-core -Dtest=McpErrorTest test
  • ./mvnw -pl mcp-core test
  • ./mvnw -pl mcp-core spring-javaformat:validate
  • git diff --check

Closes #1001

@Kehrlann

Copy link
Copy Markdown
Contributor

This is incorrect, now EVERY RESOURCE_NOT_FOUND usage will throw INVALID_PARAMS, even when it should be RESOURCE_NOT_FOUND, e.g. when a Resource does not exist

Additionally, this is a breaking change, unsure whether we will merge this before we create a 3.x branch.

@Kehrlann Kehrlann self-assigned this Jun 25, 2026
@Kehrlann Kehrlann added the waiting for user Waiting for user feedback or more details label Jun 25, 2026
@CrypticCortex

Copy link
Copy Markdown
Author

Thanks, you’re right. change is too broad because it changes every RESOURCE_NOT_FOUND caller, including cases that should keep the existing resource-not-found code.

I prepared a narrower local fix: keep RESOURCE_NOT_FOUND = -32002, and only have the SDK-owned missing resources/read fallback return SEP-2164 INVALID_PARAMS (-32602) with data: { uri }, with tests for both behaviors.

Would you prefer that update now, or should this wait for 3.x / protocol-versioned behavior?

@Kehrlann

Kehrlann commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Please apply it. I'll assign the original issue to you. Could you please comment on #1001 so I can assign you?

For when exactly we ship it, I'll keep you posted. Assigning to 3.x until we decide what to do.

@Kehrlann Kehrlann removed the waiting for user Waiting for user feedback or more details label Jun 26, 2026
@Kehrlann Kehrlann added this to the 3.x Planning milestone Jun 26, 2026
@Kehrlann Kehrlann added area/server P1 Significant bug affecting many users, highly requested feature do not merge labels Jun 26, 2026
@Kehrlann Kehrlann modified the milestones: 2.2.0-M1, 2.2.0-M2 Oct 16, 2026
@tzolov tzolov modified the milestones: 2.2.0-M2, 2.2.0-M3 Nov 2, 2026
@Kehrlann

Copy link
Copy Markdown
Contributor

Implemented as part of #1170

@Kehrlann Kehrlann closed this Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/server do not merge P1 Significant bug affecting many users, highly requested feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SEP-2164: Standardize resource not found error code (-32602)

3 participants