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