apache / apache/incubator-graphar

`PathToDirectory` can throw for valid S3 URIs without `?`

Open
#881 1 comment 0 reactions 0 assignees View on GitHub
Component:C++
Dominant language
C++
Stars
373
Forks
93
Avg merge
7d 21h
Merged PRs (30d)
7

Description

> `PathToDirectory`: for `s3://...` paths without a '?' query string, `find_last_of('?')` returns `npos` and `path.substr(t)` will throw `std::out_of_range`. Handle the `npos` case explicitly (e.g., treat it as no suffix) to avoid crashing on valid S3 URIs.
> ```suggestion
> std::string prefix;
> std::string suffix;
> if (t == std::string::npos) {
> prefix = path;
> suffix.clear();
> } else {
> prefix = path.substr(0, t);
> suffix = path.substr(t);
> }
> ```

_Originally posted by @Copilot in [#878](https://github.com/apache/incubator-graphar/pull/878/changes#r2858598451)_

Contributor guide

Open the contributing guide

Research direction

Locate the C++ PathToDirectory entry point and inspect how it splits an S3 URI around the '?' character. Reproduce the no-query-string case, handle it without throwing, and verify that URI handling with and without a suffix still behaves as expected using the relevant existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, cpp
Domain
cloud, data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.