Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jhttp: Requests with invalid ID structure are incorrectly flagged as notifications #80

Closed
creachadair opened this issue Feb 20, 2022 · 0 comments · Fixed by #81
Closed
Assignees
Labels
bug Something isn't working

Comments

@creachadair
Copy link
Owner

The bridge parses requests with jrpc2.ParseRequests. This correctly detects invalid request ID structure (e.g., {"bogus":true}), but this error is not correctly propagated. In particular, ParseRequests does not check for validation errors, and the ID field is nil when the structure was invalid.

This causes the bridge to treat the invalid request as a notification, as if its ID were not set at all. It is forwarded to the server, but the server does not see the problem since the ID on that request is not set.

Either a request needs to surface validation errors, or the bridge needs to use a smarter parsing structure.

@creachadair creachadair added the bug Something isn't working label Feb 20, 2022
@creachadair creachadair self-assigned this Feb 20, 2022
creachadair added a commit that referenced this issue Feb 20, 2022
Add a new ParsedRequest type and return that instead of Request.
This is a breaking change to the jrpc2.ParseRequests function.

The Request is meant for consumption by Handler methods where
validation has already been handled. The new type exposes validation errors,
allowing the caller to detect specific problems with each request in a batch.

This change also allows us to simplify checking of version errors, and
to remove most of the special case version checks in the client and server.

- Update the jhttp.Bridge to use the new ParsedRequest type.
- Update test cases where affected. Add a testutil package for internal tests.
- Fix handling of invalid requests in jhttp.Bridge (fixes #80).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant