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: post hook threw exception on JsonResponse #287

Conversation

taisph
Copy link
Contributor

@taisph taisph commented Aug 20, 2024

If a controller returns an Illuminate\Http\JsonResponse and you have the
OpenTelemetry traceresponse or server-timing propagator installed, the
Illuminate\Foundation\Http\Kernel::handle() post hook throws an
exception due to the ResponsePropagationSetter Illuminate\Http\Response
assertion.

Changing the Response assertion to the Symfony parent class fixes this.

Copy link

welcome bot commented Aug 20, 2024

Thanks for opening your first pull request! If you haven't yet signed our Contributor License Agreement (CLA), then please do so that we can accept your contribution. A link should appear shortly in this PR if you have not already signed one.

Copy link

linux-foundation-easycla bot commented Aug 20, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: taisph / name: Tais P. Hansen (e49b661)

@taisph taisph force-pushed the fix/post-hook-exception-on-json-response branch 3 times, most recently from 4e053c7 to f4496b3 Compare August 20, 2024 09:54
@brettmc
Copy link
Collaborator

brettmc commented Aug 20, 2024

Thanks, @taisph it looks like pretty simple. If you're able, it would be good if you could also supply a test.

Copy link

codecov bot commented Aug 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.74%. Comparing base (c6c4b3c) to head (e49b661).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #287      +/-   ##
============================================
+ Coverage     82.50%   82.74%   +0.24%     
+ Complexity     1083      495     -588     
============================================
  Files           105       48      -57     
  Lines          4578     2243    -2335     
============================================
- Hits           3777     1856    -1921     
+ Misses          801      387     -414     
Flag Coverage Δ
Aws ?
Context/Swoole 0.00% <ø> (ø)
Instrumentation/CakePHP 87.75% <ø> (ø)
Instrumentation/CodeIgniter 73.94% <ø> (ø)
Instrumentation/ExtAmqp 89.58% <ø> (ø)
Instrumentation/ExtRdKafka 87.87% <ø> (ø)
Instrumentation/Guzzle 69.73% <ø> (ø)
Instrumentation/HttpAsyncClient 81.33% <ø> (ø)
Instrumentation/IO 70.90% <ø> (ø)
Instrumentation/Laravel ?
Instrumentation/MongoDB 77.33% <ø> (ø)
Instrumentation/OpenAIPHP 86.82% <ø> (ø)
Instrumentation/PDO 89.56% <ø> (ø)
Instrumentation/Psr14 78.12% <ø> (ø)
Instrumentation/Psr15 93.50% <ø> (ø)
Instrumentation/Psr16 97.50% <ø> (ø)
Instrumentation/Psr18 82.08% <ø> (ø)
Instrumentation/Psr3 61.03% <ø> (ø)
Instrumentation/Psr6 97.61% <ø> (ø)
Instrumentation/Slim 86.95% <ø> (ø)
Instrumentation/Symfony 89.03% <ø> (ø)
Instrumentation/Yii 77.77% <ø> (ø)
Logs/Monolog 100.00% <ø> (ø)
Propagation/ServerTiming ?
Propagation/TraceResponse 100.00% <ø> (ø)
ResourceDetectors/Azure ?
ResourceDetectors/Container 93.02% <ø> (ø)
Shims/OpenTracing 92.99% <ø> (ø)
Symfony ?

Flags with carried forward coverage won't be shown. Click here to find out more.

see 57 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c6c4b3c...e49b661. Read the comment docs.

@taisph
Copy link
Contributor Author

taisph commented Aug 20, 2024

Thanks, @taisph it looks like pretty simple. If you're able, it would be good if you could also supply a test.

I can't seem to find a way to trigger a JsonResponse object through Http::fake.

Btw. I suspect a RedirectResponse will cause the same issue, but should be fixed by this change as well.

@brettmc
Copy link
Collaborator

brettmc commented Aug 20, 2024

No problem. Can you fix the build complaints (ordered imports) please?

@taisph taisph force-pushed the fix/post-hook-exception-on-json-response branch from f4496b3 to 118e835 Compare August 20, 2024 11:39
@taisph
Copy link
Contributor Author

taisph commented Aug 20, 2024

No problem. Can you fix the build complaints (ordered imports) please?

Should be fixed now.

@taisph taisph marked this pull request as ready for review August 20, 2024 11:50
@taisph taisph requested a review from a team August 20, 2024 11:50
If a controller returns an Illuminate\Http\JsonResponse and you have the
OpenTelemetry traceresponse or server-timing propagator installed, the
Illuminate\Foundation\Http\Kernel::handle() post hook throws an
exception due to the ResponsePropagationSetter Illuminate\Http\Response
assertion.

Changing the Response assertion to the Symfony parent class fixes this.
@taisph taisph force-pushed the fix/post-hook-exception-on-json-response branch from 118e835 to e49b661 Compare August 20, 2024 12:12
@bobstrecansky bobstrecansky merged commit 7bf707e into open-telemetry:main Aug 21, 2024
94 of 117 checks passed
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.

5 participants