strawberry-graphql / strawberry

A GraphQL library for Python that leverages type annotations šŸ“
https://strawberry.rocks
MIT License
4.02k stars 533 forks source link

MaskErrors does not work since version 0.240.0 #3625

Closed ericdevries closed 2 months ago

ericdevries commented 2 months ago

Since version 0.240.0, the MaskErrors extension fails to mask errors.

Describe the Bug

See example script here:

import typing
import strawberry

from strawberry.extensions import MaskErrors

@strawberry.type
class Book:
    title: str
    author: str

def get_books():
    raise Exception("Something went wrong")

@strawberry.type
class Query:
    books: typing.List[Book] = strawberry.field(resolver=get_books)

schema = strawberry.Schema(query=Query, extensions=[MaskErrors(error_message="Internal server error")])

In the previous version it would show Internal server error as the message. Since 0.240.0 it shows this:

{
  "data": null,
  "errors": [
    {
      "message": "Something went wrong",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "books"
      ]
    }
  ]
}

System Information

Additional Context

Upvote & Fund

Fund with Polar

patrick91 commented 2 months ago

I'll check this today! thanks for the report šŸ˜Š

ericdevries commented 2 months ago

Thanks!