ChilliCream / ChilliCream/graphql-platform

StrawberryShake 13.0.5 is not including GraphQLException Error Details in Response

Open
#5,897 8 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🌶️ strawberry shake repro-validated
Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
15h 39m
Merged PRs (30d)
98

Description

Is there an existing issue for this?
  • I have searched the existing issues
Product

Strawberry Shake

Describe the bug

This appears to be related to #5802, but is still happening in 13.0.5.

Background: We were running Hot Chocolate and Strawberry Shake version 12.16.0. We have an IHttpRequestInterceptor for authentication that throws a GraphQLException when our JWT is invalid. We have covered this with several integration tests.

After following your migration documentation to get everything updated to 13.0.5 in both Hot Chocolate and Strawberry Shake, our integration tests around this are now failing because the error is not hydrated in the same was as it was in 12.16.0. You can see in the below screenshots that before the update we got back our specific Error details from the GraphQLException we threw in our interceptor. The Code and Message are populated. After the update, the exact same test only has a generic 500 error message with no code populated.

When we hit the same endpoint with a bad JWT from Banana Cake Pop, we still get all the errors details we expected.

Before (12.16.0) - with Error Code and Message
StrawberryShake_v12 16 0_Response

After (13.0.5) - generic message without code
StrawberryShake_v13 0 5_Response

Steps to reproduce
  1. Write an IHttpRequestInterceptor that throws a GraphQLException something like this:
public class TestInterceptor : DefaultHttpRequestInterceptor
{
    public override async ValueTask OnCreateAsync(
        HttpContext context,
        IRequestExecutor requestExecutor,
        IQueryRequestBuilder requestBuilder,
        CancellationToken cancellationToken)
    {
        await base.OnCreateAsync(context, requestExecutor, requestBuilder, cancellationToken);
        throw new GraphQLException(new Error(
            "Authentication Failed",
            code: "401", 
            exception: new Exception("Failed to authenticate")
        ));
    }
}
  1. Use .AddHttpRequestInterceptor(...) to register the interceptor.
  2. Make an HTTP request using StrawberryShake and inspect the result. Notice the details from the Error provided to the GraphQL exception are not present.
Relevant log output

No response

Additional Context?

No response

Version

13.0.5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the IHttpRequestInterceptor and GraphQLException flow described in the reproduction, then compare the 12.16.0 and 13.0.5 response behavior through an integration test. Register the interceptor with AddHttpRequestInterceptor, make the failing request, and verify that the GraphQL error code and message are present rather than a generic 500 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, authentication
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.