ChilliCream / ChilliCream/graphql-platform
Strawberry Shake No Longer Returning Client Errors in a Request Under Certain Circumstances
Nobody has claimed this yet.
- 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
I'm using Strawberrry Shake as a client in a suite of tests. Our tests cover many scenarios including those that should cause a validation error. Specifically, we have tests that send requests that have either empty or null parameters when they are specifically not allowed. Those tests then verify that the proper validation error comes back.
If it has any bearing on this issue, our GraphQL gateway that I am testing against is running HotChocolate.
We had been using v13.5.1 for a while and today I tried to upgrade to v13.7.0. This causes our tests covering the scenarios I described above to start failing. From what I can tell, the full validation error is no longer being properly deserialized by Strawberry Shake
Here is an example of a request sent with an empty parameter value (that should not be):
{
"id": "e921924e5acc17d99e15700782fe315e",
"query": "mutation CreateDatabaseConnection($database: CreateDatabaseConnectionInput!) { createDatabaseConnection(input: $database) { __typename databaseConnection { __typename id name } errors { __typename ... on Error { code statusCode message } ... on DatabaseConnectionAlreadyExistsError { databaseName service } ... on InvalidDatabaseConnectionFormatError { databaseName service } ... on UserManagementServiceError { service } ... on Auth0UnavailableError { service } } } }",
"operationName": "CreateDatabaseConnection",
"variables": {
"database": {
"databaseName": ""
}
}
}
And here is the response I get back. As you can see, the status code is 500 and the response contains no data object. This is expected.
HTTP/1.1 500 Internal Server Error
Date: Fri, 01 Dec 2023 21:15:10 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: Kestrel
{
"errors": [
{
"message": "NonEmptyStringType cannot parse the provided literal. The provided string was empty.",
"path": [
"database",
"databaseName"
],
"extensions": {
"code": "HC0002",
"actualType": "NonEmptyString",
"field": "CreateDatabaseConnectionInput.databaseName",
"fieldType": "NonEmptyString"
}
}
]
}
While the raw response I get back is correct regardless if I use v13.5.1 or v13.7.0, the resulting response object is not.
I debugged my tests in my IDE and below is the result object returned by Strawberry Shake.
This screenshot is using v13.5.1.
And this screenshot is using v13.7.0
As you can see, I get the full error in the first ClientError in v13.5.1. In v13.7.0, all I am seeing is a generic message stating "Response status code does not indicate success: 500 (Internal Server Error). None of the other properties on the ClientError object are populated.
After some trial and error, I discovered that this issue was introduced in v13.6.0-preview.33. Up until that version, everything was working as expected.
I should also note that I have seen something similar before in this issue https://github.com/ChilliCream/graphql-platform/issues/5684#issuecomment-1463836382
Steps to reproduce
Since our GraphQL gateways are not open for public use, this is the best way I can describe to duplicate the issue.
- Find a GraphQL gateway that has a mutation that takes in multiple parameters. At least one of the parameters must not be allowed to be empty. The gateway should return a validation error and a 500 response if the parameter is empty.
- Submit a request to the gateway using Strawberry Shake with that mutation and make sure the parameter is an empty string.
- Look at the OperationResult that is returned. The ClientError array should have a single object. The details of the validation error should be present but are not.
Relevant log output
No response
Additional Context?
No response
Version
13.7.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the request against a gateway that returns the described validation error, then compare Strawberry Shake v13.5.1 with v13.7.0 while inspecting the returned OperationResult and ClientError values. Trace the response handling introduced in v13.6.0-preview.33; done means the validation error details are populated again for the 500 response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100