{"record":{"id":"149a9ba98b4090ed","repo":"apache/beam","slug":"can-t-resolve-the-sibling-of-a-root-path-s","errorCode":null,"errorMessage":"Can't resolve the sibling of a root path: %s","messagePattern":"Can't resolve the sibling of a root path: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/gcsfs/GcsPath.java","lineNumber":432,"sourceCode":"\n    if (object.isEmpty()) {\n      return new GcsPath(fs, bucket, other);\n    } else if (object.endsWith(\"/\")) {\n      return new GcsPath(fs, bucket, object + other);\n    } else {\n      return new GcsPath(fs, bucket, object + \"/\" + other);\n    }\n  }\n\n  @Override\n  public Path resolveSibling(Path other) {\n    throw new UnsupportedOperationException();\n  }\n\n  @Override\n  public Path resolveSibling(String other) {\n    if (getNameCount() < 2) {\n      throw new UnsupportedOperationException(\"Can't resolve the sibling of a root path: \" + this);\n    }\n    GcsPath parent = getParent();\n    return (parent == null) ? fromUri(other) : parent.resolve(other);\n  }\n\n  @Override\n  public Path relativize(Path other) {\n    throw new UnsupportedOperationException();\n  }\n\n  @Override\n  public GcsPath toAbsolutePath() {\n    return this;\n  }\n\n  @Override\n  public GcsPath toRealPath(LinkOption... options) throws IOException {\n    return this;","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/gcsfs/GcsPath.java#L414-L450","documentation":"resolveSibling resolves the given path against this path's parent. A bucket-root GcsPath (only scheme+bucket, getNameCount() < 2) has no resolvable parent context, so the method throws UnsupportedOperationException.","triggerScenarios":"Calling resolveSibling(Path) or resolveSibling(String) on a GcsPath with fewer than two name components, e.g. on 'gs://bucket'.","commonSituations":"Generic path-joining code (e.g. computing sibling files, config-relative paths) applied to a bucket root URI; refactoring local file code to GCS paths without checking depth.","solutions":["Guard with getNameCount() >= 2 before calling resolveSibling","Resolve against the desired bucket explicitly: GcsPath.fromUri(\"gs://bucket/\").resolve(other)","Rework the algorithm to build target paths from the bucket root instead of siblings"],"exampleFix":"// before\nPath sibling = gcsPath.resolveSibling(other);\n// after\nPath sibling = gcsPath.getNameCount() >= 2\n    ? gcsPath.resolveSibling(other)\n    : GcsPath.fromUri(\"gs://\" + gcsPath.getBucket() + \"/\").resolve(other);","handlingStrategy":"type-guard","validationCode":"if (path.getNameCount() < 2) { throw new IllegalArgumentException(\"Cannot resolve sibling of root path \" + path); }","typeGuard":"boolean canResolveSibling(GcsPath p) { return p.getNameCount() >= 2; }","tryCatchPattern":"try { return path.resolveSibling(other); } catch (UnsupportedOperationException e) { return GcsPath.fromUri(\"gs://\" + ((GcsPath) path).getBucket() + \"/\").resolve(other); }","preventionTips":["Avoid generic java.nio.Path algorithms on bucket-root paths","Build sibling paths from the bucket root explicitly","Test path-joining helpers with gs://bucket-only inputs"],"tags":["gcs","java","path","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}