When registering instantiated extensions, the execution context field on the extension is set and hence when there are multiple requests in-flight (e.g. when using async) this can resulting in inconsistent results - e.g. errors not being masked when using the MaskErrorExtension
When registering the masked error extension via
schema = strawberry.Schema(
Query,
extensions=[
MaskErrors(),
],
)
If there are multiple requests in flight, then some errors are not masked. This seems to be because Strawberry edits the execution context on the shared extension, meaning that the error masking logic may operate on the wrong execution context (e.g. one that has not completed).
--SchemaExtensionRunner
for extension in extensions:
# If the extension has already been instantiated then set the
# `execution_context` attribute
if isinstance(extension, SchemaExtension):
extension.execution_context = execution_context <---here
init_extensions.append(extension)
else:
init_extensions.append(extension(execution_context=execution_context))
This could be fixed by cloning the extension for each request - or by following the field extension pattern of passing the context as a method parameter
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too