fix(cpp): Handle npos in PathToDirectory for S3 URIs without query strings#888
fix(cpp): Handle npos in PathToDirectory for S3 URIs without query strings#888shivendra-dev54 wants to merge 1 commit intoapache:mainfrom
Conversation
|
@Sober7135 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #888 +/- ##
============================================
+ Coverage 79.81% 79.86% +0.04%
Complexity 615 615
============================================
Files 93 93
Lines 10296 10296
Branches 1055 1055
============================================
+ Hits 8218 8223 +5
+ Misses 1838 1833 -5
Partials 240 240
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This is not quite accurate, since no test case was added for this bug. Testing this bug is also somewhat complicated, because More importantly, this bug is only exercised through incubator-graphar/cpp/src/graphar/graph_info.cc Lines 1405 to 1416 in d535a43 I can think of two possible solutions:
Actually, I am not familiar with this kind of problem. Any advice? CC @yangxk1 |
Reason for this PR
Fixes #881
PathToDirectorywas crashing with astd::out_of_rangeexception when parsing valid S3 URIs that do not contain a query string (?). This happens becausefind_last_of('?')returnsstd::string::npos, which was being passed directly intopath.substr().What changes are included in this PR?
Added an explicit check for
std::string::nposinPathToDirectory. When an S3 URI without a query string is processed, it now correctly identifies the entire path as the prefix and sets the suffix to an empty string, safely avoiding the out-of-bounds crash.Are these changes tested?
Yes, the C++ test suite was compiled and run locally, and all tests pass successfully.
Are there any user-facing changes?
No.
Critical Fix: Fixes a bug that causes a crash (
std::out_of_rangeexception) when parsing valid S3 URIs without query strings.