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

[EXPORTER] handling of invalid ports in UrlParser #3142

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

sjinks
Copy link
Contributor

@sjinks sjinks commented Nov 14, 2024

Fixes #3138

Changes

This PR adds handling of invalid ports to UrlParser.

Previously, invalid ports caused an exception; this PR updated the code so as not to throw exceptions and set success_ to false.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@sjinks sjinks requested a review from a team as a code owner November 14, 2024 15:51
Copy link

netlify bot commented Nov 14, 2024

Deploy Preview for opentelemetry-cpp-api-docs canceled.

Name Link
🔨 Latest commit 06bab4c
🔍 Latest deploy log https://app.netlify.com/sites/opentelemetry-cpp-api-docs/deploys/67361d3bbae88c00083195df

Comment on lines +93 to +94
url_.begin() + static_cast<std::string::difference_type>(cpos),
url_.begin() + static_cast<std::string::difference_type>(url_.length()));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

static_cast<> is because "Narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'difference_type' (aka 'long') is implementation-defined"

See also: https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.html

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 2 lines in your changes missing coverage. Please review.

Project coverage is 87.83%. Comparing base (497eaf4) to head (06bab4c).
Report is 164 commits behind head on main.

Files with missing lines Patch % Lines
...include/opentelemetry/ext/http/common/url_parser.h 85.72% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3142      +/-   ##
==========================================
+ Coverage   87.12%   87.83%   +0.72%     
==========================================
  Files         200      195       -5     
  Lines        6109     6146      +37     
==========================================
+ Hits         5322     5398      +76     
+ Misses        787      748      -39     
Files with missing lines Coverage Δ
...include/opentelemetry/ext/http/common/url_parser.h 93.34% <85.72%> (+1.34%) ⬆️

... and 112 files with indirect coverage changes

Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix.

@marcalff marcalff changed the title fix: handling of invalid ports in UrlParser [EXPORTER] handling of invalid ports in UrlParser Nov 14, 2024
@marcalff marcalff merged commit 149d29c into open-telemetry:main Nov 14, 2024
56 checks passed
malkia added a commit to malkia/opentelemetry-cpp that referenced this pull request Nov 14, 2024
[EXPORTER] handling of invalid ports in UrlParser (open-telemetry#3142)
@sjinks sjinks deleted the GH-3138 branch November 15, 2024 10:59
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.

URL parser throws an exception
3 participants