{"record":{"id":"b8ca296c37fd4f71","repo":"apache/beam","slug":"expected-a-valid-gs-path-but-was-given-s","errorCode":null,"errorMessage":"Expected a valid 'gs://' path but was given '%s'","messagePattern":"Expected a valid 'gs://' path but was given '(.+?)'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/storage/GcsPathValidator.java","lineNumber":93,"sourceCode":"        !gcsPath.getObject().contains(\"//\"),\n        \"Dataflow Service does not allow objects with consecutive slashes\");\n    return gcsPath.toResourceName();\n  }\n\n  private void verifyPathIsAccessible(String path, String errorMessage) {\n    GcsPath gcsPath = getGcsPath(path);\n    try {\n      gcpOptions.getGcsUtil().verifyBucketAccessible(gcsPath);\n    } catch (IOException e) {\n      throw new RuntimeException(String.format(errorMessage, path), e);\n    }\n  }\n\n  private GcsPath getGcsPath(String path) {\n    try {\n      return GcsPath.fromUri(path);\n    } catch (IllegalArgumentException e) {\n      throw new IllegalArgumentException(\n          String.format(\"Expected a valid 'gs://' path but was given '%s'\", path), e);\n    }\n  }\n}\n","sourceCodeStart":75,"sourceCodeEnd":98,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/storage/GcsPathValidator.java#L75-L98","documentation":"GcsPathValidator.getGcsPath converts a user-supplied path string to a GcsPath via GcsPath.fromUri. If the string is not a valid gs:// URI, fromUri throws IllegalArgumentException, which is rethrown with 'Expected a valid 'gs://' path but was given '%s''. It guards all GCS input/output validation entry points.","triggerScenarios":"Passing a local filesystem path (e.g. /tmp/out or file:///tmp), a bare bucket name, or a malformed URI (gs:/bucket, gs://) to validateInputFilePatternSupported or validateOutputFilePrefixSupported.","commonSituations":"Config defaulting to local paths when running on Dataflow; missing 'gs://' scheme after string concatenation; Windows-style paths pasted into options.","solutions":["Prefix the path with gs:// (full form gs://bucket/path)","Check the option/value being passed for accidental local-path defaults","Use GcsPath.fromUri in your own code to fail fast with the raw URI problem"],"exampleFix":"// before\nString output = \"/home/user/output/prefix\";\n// after\nString output = \"gs://my-bucket/output/prefix\";","handlingStrategy":"validation","validationCode":"boolean isGcsPath(String s) {\n  try { GcsPath.fromUri(s); return true; } catch (IllegalArgumentException e) { return false; }\n}\n// call before validate: if (!isGcsPath(output)) output = \"gs://\" + output;","typeGuard":"boolean isGcsUri(String s) { return s != null && s.startsWith(\"gs://\") && GcsPath.fromUri(s).getBucket() != null; }","tryCatchPattern":"try { GcsPath.fromUri(path); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(\"Not a gs:// path: \" + path, e); }","preventionTips":["Normalize paths to gs:// form at config load time","Reject file:// or bare paths early when running on Dataflow","Unit-test option parsing with representative path values"],"tags":["gcs","uri","validation","java"],"backgroundTag":"invalid-url-format","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}