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

MaskErrors does not mask errors for subscriptions #3680

Open
axiomofjoy opened this issue Oct 25, 2024 · 1 comment
Open

MaskErrors does not mask errors for subscriptions #3680

axiomofjoy opened this issue Oct 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@axiomofjoy
Copy link

axiomofjoy commented Oct 25, 2024

The MaskErrors schema extension does not seem to mask errors for subscriptions. I am running on the latest version of strawberry. Example included below:

from typing import AsyncIterator
import strawberry
from strawberry.extensions import MaskErrors


@strawberry.type
class Query:
    @strawberry.field
    def hello(self) -> str:
        raise Exception("boom")
        return "world"


@strawberry.type
class Subscription:
    @strawberry.subscription
    async def stream(self) -> AsyncIterator[str]:
        yield "hello"
        yield "world"
        raise Exception("boom")


schema = strawberry.Schema(
    query=Query, subscription=Subscription, extensions=[MaskErrors()]
)

The errors are masked for queries:

Image

But not for subscriptions:

Image

Describe the Bug

I expect the MaskErrors extension to mask my errors for subscriptions as well as queries and mutations, but it does not appear to do so.

System Information

  • Operating system: MacOS
  • Strawberry version (if applicable): 0.247.0

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@Speedy1991
Copy link
Contributor

Speedy1991 commented Oct 25, 2024

Can confirm this - the problem is, a subscriptions never sets an execution_context.result (it is always None) and therefore the error check failes.

I think the problem is send_next because it just formats the error and in line 381 it send the message without going through the gql middlewares

Same problem in the graphql-ws implementation here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants