Skip to content

[Server] Add UnknownMethodException instead of matching on the error message - #681

Merged
chr-hertel merged 2 commits into
mainfrom
simplify-message-factory
Nov 8, 2026
Merged

chr-hertel merged 2 commits into
mainfrom
simplify-message-factory

Conversation

@chr-hertel

@chr-hertel chr-hertel commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #680. UnknownMethodException replaces matching on the error message to tell -32601 from -32600 in stateless dispatch. The JSON round trip next to it went away with #678.

A request class crashing while hydrating is still answered with -32601 - -32603 looks more accurate, but that's a behavior change, so not part of this one.

@chr-hertel chr-hertel added the Server Issues & PRs related to the Server component label Nov 8, 2026
@chr-hertel chr-hertel changed the title [Server] Parse decoded messages without a JSON round trip [Server] Add UnknownMethodException instead of matching on the error message Nov 8, 2026
Base automatically changed from remove-batch-support to main November 8, 2026 12:50
@chr-hertel chr-hertel added this to the 0.10.0 milestone Nov 8, 2026
Add MessageFactory::fromArray() and UnknownMethodException, so stateless
dispatch stops re-encoding its input and matching on an error message.
@chr-hertel
chr-hertel force-pushed the simplify-message-factory branch from 42a4329 to e43b105 Compare November 8, 2026 13:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain to block approval.

No open issues 🎉

What changed in this PR

Replaces error-message matching in stateless server dispatch with a dedicated UnknownMethodException, preserving existing error responses and compatibility with InvalidInputMessageException handlers.

Changes:

  • Add and document the exception for unregistered methods.
  • Distinguish unknown methods from malformed requests by exception type.
  • Update tests to cover the exception type, malformed parameters, and hydration failures.
File Description
tests/​Unit/​Server/​Stateless/​StatelessProtocolTest.php Add malformed-request and hydration-failure regression tests.
tests/​Unit/​JsonRpc/​MessageFactoryTest.php Expect the dedicated unknown-method exception.
src/​Server/​Stateless/​StatelessProtocol.php Replace message matching with a typed catch.
src/​JsonRpc/​MessageFactory.php Throw and document UnknownMethodException.
src/​Exception/​UnknownMethodException.php Define the InvalidInputMessageException subclass.
CHANGELOG.md Document the new exception.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants