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 URI::InvalidURIError #2310

Merged
merged 2 commits into from
Oct 13, 2022

Conversation

yujideveloper
Copy link
Contributor

What does this PR do?

This fixes URI::InvalidURIError when it runs on WEBrick.
This error introduced in v1.5.0 (#2265).

Additional Notes

env['REQUEST_URI'] is often only path, but in some environments (e.g. WEBrick) it contains the base url (e.g. http://localhost:3000/foo/bar).
https://github.com/ruby/webrick/blob/v1.7.0/lib/webrick/httprequest.rb#L423
https://github.com/ruby/webrick/blob/v1.7.0/lib/webrick/httprequest.rb#L218
https://github.com/ruby/webrick/blob/v1.7.0/lib/webrick/httprequest.rb#L484-L505

How to test the change?

Start rails server on WEBrick and access app via web browser (e.g. http://localhost:300/foo).

My environment is below:

  • Ruby 2.7.5
  • ddtrace 1.5.0
  • rack 2.2.4
  • webrick 1.7.0
  • rails 5.2.8.1

`env['REQUEST_URI']` is often only path, but in some environments
(e.g. WEBrick) it containts the base url.
@yujideveloper yujideveloper requested a review from a team October 12, 2022 14:50
@github-actions github-actions bot added integrations Involves tracing integrations tracing labels Oct 12, 2022
@codecov-commenter
Copy link

codecov-commenter commented Oct 12, 2022

Codecov Report

Merging #2310 (450c7cd) into master (f5984e8) will decrease coverage by 0.02%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2310      +/-   ##
==========================================
- Coverage   97.58%   97.55%   -0.03%     
==========================================
  Files        1094     1076      -18     
  Lines       57400    56792     -608     
==========================================
- Hits        56015    55405     -610     
- Misses       1385     1387       +2     
Impacted Files Coverage Δ
...iling_native_extension/native_extension_helpers.rb 96.15% <ø> (ø)
lib/ddtrace/transport/http/env.rb 92.85% <0.00%> (-3.58%) ⬇️
lib/datadog/core/workers/polling.rb 96.55% <0.00%> (-3.45%) ⬇️
...adog/core/configuration/agent_settings_resolver.rb 96.75% <0.00%> (-2.60%) ⬇️
lib/datadog/core/diagnostics/environment_logger.rb 98.41% <0.00%> (-1.59%) ⬇️
lib/datadog/core/configuration/settings.rb 98.41% <0.00%> (-0.53%) ⬇️
spec/support/container_helpers.rb 99.55% <0.00%> (-0.45%) ⬇️
lib/datadog/core.rb 87.50% <0.00%> (ø)
lib/datadog/profiling/exporter.rb 100.00% <0.00%> (ø)
lib/datadog/core/utils/compression.rb 100.00% <0.00%> (ø)
... and 25 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@lloeki
Copy link
Contributor

lloeki commented Oct 12, 2022

@yujideveloper Thanks for this fix!

I updated your branch with a couple of additional test cases. Otherwise, LGTM!

@yujideveloper
Copy link
Contributor Author

@lloeki
Thank you for adding your test cases!

Copy link
Contributor

@TonyCTHsu TonyCTHsu left a comment

Choose a reason for hiding this comment

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

Looks good!

@TonyCTHsu TonyCTHsu merged commit 4e7ecda into DataDog:master Oct 13, 2022
@github-actions github-actions bot added this to the 1.6.0 milestone Oct 13, 2022
@yujideveloper yujideveloper deleted the bugfix/invalid-uri-error branch October 13, 2022 11:07
@lloeki
Copy link
Contributor

lloeki commented Oct 19, 2022

Hey @yujideveloper, this has been released as part of 1.5.1, thank you for your contribution!

@gingerlime
Copy link
Contributor

#2265 (comment)

@lloeki
Copy link
Contributor

lloeki commented Oct 24, 2022

Sadly this triggers #2309 again, which was fixed by #2311 and had specs added, yet evaded these new spec examples 😓. Working on a fix.

integration_test_5

@lloeki
Copy link
Contributor

lloeki commented Oct 27, 2022

@gingerlime FYI the fix in #2328 has been released in v1.5.2

@gingerlime
Copy link
Contributor

Thanks so much @lloeki 👍 🙏

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

Successfully merging this pull request may close these issues.

5 participants