Repository navigation
[Server] Add UnknownMethodException instead of matching on the error message - #681
Merged
Merged
Conversation
chr-hertel
requested review from
CodeWithKyrian,
Nyholm and
soyuka
as code owners
November 8, 2026 12:32
UnknownMethodException instead of matching on the error message
Add MessageFactory::fromArray() and UnknownMethodException, so stateless dispatch stops re-encoding its input and matching on an error message.
chr-hertel
force-pushed
the
simplify-message-factory
branch
from
November 8, 2026 13:19
42a4329 to
e43b105
Compare
Contributor
There was a problem hiding this comment.
🟢 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
This was referenced Nov 10, 2026
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.
Follow-up to #680.
UnknownMethodExceptionreplaces matching on the error message to tell-32601from-32600in stateless dispatch. The JSON round trip next to it went away with #678.A request class crashing while hydrating is still answered with
-32601--32603looks more accurate, but that's a behavior change, so not part of this one.