Skip to content

PathToDirectory can throw for valid S3 URIs without ? #881

@Sober7135

Description

@Sober7135

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.

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions