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

Forward PHP engine errors to the application error handler #487

Merged
merged 3 commits into from
Oct 20, 2019

Conversation

mfn
Copy link
Collaborator

@mfn mfn commented Oct 12, 2019

Otherwise PHP errors, like TypeError happening (as part of bugs 🤷‍♀️) inside PHP code executed in GraphQL queries are not reported via the application error handler.

Only a regular "internal error" was returned but the actual error was nowhere found in the logs or 3rd party error handling services.

TODO

  • Add test
  • Need to find another way to trigger such error because otherwise PHPStan/Larastan complaints because it "sees" that the code is wrong

Note

This is a change in behaviour of the library and thus subject to semver requiring a major version bump (as established in #481 (comment) ). I.e. the next release has to be 3 after this is merged.

@mfn mfn self-assigned this Oct 12, 2019
@mfn mfn force-pushed the mfn-engine-errors branch 4 times, most recently from de0142b to 6c096f8 Compare October 12, 2019 18:11
@mfn
Copy link
Collaborator Author

mfn commented Oct 12, 2019

FTR, I ran into this in a project I'm working on. There was a bug in the PHP code but because it was an engine error (it isn't in the Exception hierarchy but Error <- Throwable, I only got back an "internal error" from GraphQL but nothing in the laravel log because ->report() was not called on it

- 5.6: bug fixes ended on August 7th, 2018 and security fixes on February 7th, 2019
- 5.7: bug fixes ended on March 4th, 2019 and security fies on September 4th, 2019

Also: there's some weird edge case bug with 5.7 in the test \Rebing\GraphQL\Tests\Unit\SchemaHyphenInPathTest::testWithHyphen which makes it fail, see https://travis-ci.org/rebing/graphql-laravel/jobs/579289418 (this build was previously green until I restarted it recently):
```
1) Rebing\GraphQL\Tests\Unit\SchemaHyphenInPathTest::testWithHyphen

Failed asserting that exception of type "ErrorException" matches expected exception "Symfony\Component\HttpKernel\Exception\NotFoundHttpException". Message was: "Invalid argument supplied for foreach()" at

/home/travis/build/rebing/graphql-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:739

/home/travis/build/rebing/graphql-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:718

/home/travis/build/rebing/graphql-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:690

/home/travis/build/rebing/graphql-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:756

/home/travis/build/rebing/graphql-laravel/tests/Unit/SchemaHyphenInPathTest.php:29
```
Locally everything is working fine so I don't see a reason to pursue this further.
Using a "real PHP error" would always trigger PHPStan to actually report it
and this abort the travis testing pipeline.
@mfn mfn merged commit 07147f6 into rebing:master Oct 20, 2019
@mfn mfn deleted the mfn-engine-errors branch October 20, 2019 17:01
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

1 participant