Skip to content

Fix nil pointer dereference with malformed URLs when tracing enabled #1055

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

Merged
merged 6 commits into from
Aug 11, 2025

Conversation

Peakz
Copy link
Contributor

@Peakz Peakz commented Jul 9, 2025

  • Ensure convert() always returns http.Request with valid URL field
  • Prevents panic in sentry.NewRequest() when transaction.Finish() is called
  • Affects both Fiber and FastHTTP integrations

Fixes #1054

- Ensure convert() always returns http.Request with valid URL field
- Prevents panic in sentry.NewRequest() when transaction.Finish() is called
- Affects both Fiber and FastHTTP integrations

Fixes getsentry#1054
@cleptric
Copy link
Member

cleptric commented Jul 9, 2025

Can you please add a test case as well?

Copy link

codecov bot commented Jul 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.88%. Comparing base (55af278) to head (9172134).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1055   +/-   ##
=======================================
  Coverage   86.87%   86.88%           
=======================================
  Files          55       55           
  Lines        5952     5956    +4     
=======================================
+ Hits         5171     5175    +4     
  Misses        638      638           
  Partials      143      143           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Tests verify that malformed URLs don't cause panics when tracing is
enabled, covering the fix for issue getsentry#1054.
@Peakz
Copy link
Contributor Author

Peakz commented Jul 9, 2025

Those should do it

@cleptric cleptric self-requested a review July 13, 2025 15:59
@cleptric cleptric self-assigned this Jul 13, 2025
@cleptric cleptric added the Bug Issue type label Jul 13, 2025
@@ -151,10 +151,11 @@ func convert(ctx *fasthttp.RequestCtx) *http.Request {

r.Method = string(ctx.Method())

r.URL = &url.URL{Path: "/"}
Copy link
Member

Choose a reason for hiding this comment

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

Could we somehow maintain a version with the raw URL instead of /?

Copy link
Contributor

@giortzisg giortzisg Aug 7, 2025

Choose a reason for hiding this comment

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

We could use the uri.Path as a fallback here? @Peakz

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies for the delay. I have now updated the solution to use uri.Path since it preserves the raw URL instead of the hardcoded /. Thanks for the suggestion, @giortzisg!

cursor[bot]

This comment was marked as outdated.

@cleptric cleptric merged commit 17421c4 into getsentry:master Aug 11, 2025
18 checks passed
@giortzisg
Copy link
Contributor

@Peakz the fix was just released with v0.35.1.

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

Successfully merging this pull request may close these issues.

Fiber integration: nil pointer dereference with malformed URLs when tracing enabled
3 participants