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

fix: avoid panic from tracing on bad request #2871

Merged
merged 1 commit into from Dec 29, 2023

Conversation

SteveRuble
Copy link
Contributor

This fixes a panic which arises from the tracing components when a request has some defect which results in an error when creating the OperationContext. The transports consistently handle this by calling DispatchError(graphql.WithOperationContext(ctx, rc), err) where rc is the OperationContext which was not correctly constructed. This seems dangerous, because middleware may assume that if there in an OperationContext in the context.Context than they are being invoked on a normal codepath and can assume their other interceptors have been invoked in the normal order. Also, using a value returned by a function which also returned a non-nil error is very unusual. However, I have no idea what the impact of changing that dangerous behavior in the transports would be, so I opted to make the tracing component more resilient instead.

I have:

  • Added tests covering the bug / feature (see testing)
  • Updated any relevant documentation (see docs)

This fixes a panic which arises from the tracing components when a request has some defect which results in an error when creating the operation context. The transports consistently handle this by calling `DispatchError(graphql.WithOperationContext(ctx, rc), err)` where `rc` is the OperationContext which was not correctly constructed. This seems dangerous, because middleware may assume that if there in an `OperationContext` in the `context.Context` than they are being invoked on a normal codepath and can assume their other interceptors have been invoked in the normal order. Also, using a value returned by a function which also returned a non-nil error is very unusual. However, I have no idea what the impact of changing that dangerous behavior in the transports would be, so I opted to make the tracing component more resilient instead.
@coveralls
Copy link

coveralls commented Dec 29, 2023

Coverage Status

coverage: 75.957% (+0.03%) from 75.93%
when pulling 39e332b on SteveRuble:master
into 13bb415 on 99designs:master.

@StevenACoffman StevenACoffman merged commit c811d47 into 99designs:master Dec 29, 2023
18 checks passed
@StevenACoffman
Copy link
Collaborator

Thanks very much! This is much appreciated, and I look forward to future PRs from you!

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.

None yet

4 participants