Skip to content

MaskErrors cannot deal with PreExecutionResultΒ #3959

@ericdevries

Description

@ericdevries

Describe the Bug

Between an update from 0.276 to 0.278, a new error started occuring for the MaskErrors extension. For some reason, this error is now popping up:

'PreExecutionError' object has no attribute 'initial_result'

The code we use for testing:

async def test_invalid(test_client: AsyncClient):
    query = """
        {
          anomalies(filter: {mrid: "12345678"}) {
            items {
              mrid
            }
          }
        }
    """

    response = await test_client.post(
        "/graphql",
        json={
            "query": query,
        },
    )

    response_json = response.json()
    assert "errors" in response_json

    assert (
        response_json["errors"][0]["message"]
        == 'Value cannot represent a UUID: "12345678". badly formed hexadecimal UUID string'
    )

Server config:

def should_mask_error(error: GraphQLError) -> bool:
    """
    Mask all errors except explicitly raised ones and our own InputValidationError.
    """
    return (
        error.original_error is not None
        and not isinstance(error.original_error, InputValidationError)
        and not isinstance(error.original_error, GraphQLError)
    )


schema = Schema(
    query=Query,
    mutation=Mutation,
    extensions=[MaskErrors(should_mask_error=should_mask_error, error_message="An unexpected error occured")],
    scalar_overrides={
        datetime: ZuluDateTime,
        DatetimeRange: ZuluDateTimeRange,
    },
)

System Information

  • Operating system:
  • Python version:
  • Strawberry version (if applicable):

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions