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

Fix bug with errors thrown in the on_parse_* extension hooks #1324

Merged
merged 1 commit into from Oct 11, 2021

Conversation

jkimbo
Copy link
Member

@jkimbo jkimbo commented Oct 10, 2021

Description

Before they would have been swallowed and just returned in the results
object. This change means that they get propagated up as you would
expect.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Before they would have been swallowed and just returned in the results
object. This change means that they get propagated up as you would
expect.
@botberry
Copy link
Member

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


Fix bug where errors thrown in the on_parse_* extension hooks were being
swallowed instead of being propagated.


Here's the preview release card for twitter:

Here's the tweet text:

🆕 Release (next) is out! Thanks to Jonathan Kim for the PR 👏

Get it here 👉 https://github.com/strawberry-graphql/strawberry/releases/tag/(next)

@codecov
Copy link

codecov bot commented Oct 10, 2021

Codecov Report

Merging #1324 (b94af9d) into main (697f258) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1324   +/-   ##
=======================================
  Coverage   98.04%   98.04%           
=======================================
  Files         105      105           
  Lines        3786     3786           
  Branches      547      547           
=======================================
  Hits         3712     3712           
  Misses         41       41           
  Partials       33       33           

Copy link
Member

@DoctorJohn DoctorJohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find! Fix and tests look sensible to me 👍

Comment on lines +81 to +89
except Exception as error: # pragma: no cover
error = GraphQLError(str(error), original_error=error)

execution_context.errors = [error]
return ExecutionResult(
data=None,
errors=[error],
extensions=await extensions_runner.get_extensions_results(),
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed while investigating #3204:

Looks like this block should not have been moved or kept at all. Now it's catching Exceptions raised by parse_document, which there shouldn't be any.

Before it was moved, it used to catch errors raised inside extensions during the parsing step and add those to the execution result. Such errors are usually progamming errors which we might prefer to cause an internal server error instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants