{"record":{"id":"766bea8a7bc875d9","repo":"apache/beam","slug":"the-specified-file-does-not-exist-s","errorCode":null,"errorMessage":"The specified file does not exist: %s","messagePattern":"The specified file does not exist: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/GcsUtilV2.java","lineNumber":129,"sourceCode":"      case 404:\n        return new FileNotFoundException(e.getMessage());\n      case 409:\n        return new FileAlreadyExistsException(gcsPath.toString(), null, e.getMessage());\n      default:\n        return new IOException(e);\n    }\n  }\n\n  private IOException translateStorageException(\n      String bucketName, @Nullable String blobName, StorageException e) {\n    return translateStorageException(GcsPath.fromComponents(bucketName, blobName), e);\n  }\n\n  public Blob getBlob(GcsPath gcsPath, BlobGetOption... options) throws IOException {\n    try {\n      Blob blob = storage.get(gcsPath.getBucket(), gcsPath.getObject(), options);\n      if (blob == null) {\n        throw new FileNotFoundException(\n            String.format(\"The specified file does not exist: %s\", gcsPath.toString()));\n      }\n      return blob;\n    } catch (StorageException e) {\n      throw translateStorageException(gcsPath, e);\n    }\n  }\n\n  public long fileSize(GcsPath gcsPath) throws IOException {\n    return getBlob(gcsPath, BlobGetOption.fields(BlobField.SIZE)).getSize();\n  }\n\n  /** A class that holds either a {@link Blob} or an {@link IOException}. */\n  @AutoValue\n  public abstract static class BlobResult {\n\n    /** Returns the {@link Blob}. */\n    public abstract @Nullable Blob blob();","sourceCodeStart":111,"sourceCodeEnd":147,"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/GcsUtilV2.java#L111-L147","documentation":"GcsUtilV2.getBlob fetches a Blob via the com.google.cloud.storage.Storage client and throws FileNotFoundException when Storage.get returns null, i.e. the object does not exist (or the caller lacks visibility). StorageExceptions are translated separately.","triggerScenarios":"Any call path through getBlob — fileSize(gcsPath), expand(gcsPath), or blob(...) — where the (bucket, object) pair does not exist, e.g. wrong object path, object deleted, or getBlob called before a write completes.","commonSituations":"Stale file listing cached by a caller; typos or wrong templated file paths in pipeline options; eventual consistency windows in listing vs. get in concurrent writes; reading a match-generated path that matched zero files is guarded elsewhere but direct paths can 404.","solutions":["Verify the gs:// path exists: gsutil ls <path> or storage.get via console.","Check the file path/template configuration for typos or stale values.","Guard with gcsUtil.expand/gcsUtil.treeList over a directory pattern before calling fileSize/getBlob.","Handle FileNotFoundException at the call site when the file is optional."],"exampleFix":"// before\nlong size = gcsUtil.fileSize(GcsPath.fromUri(path));\n// after\ntry {\n  long size = gcsUtil.fileSize(GcsPath.fromUri(path));\n} catch (FileNotFoundException e) {\n  LOG.warn(\"Skipping missing object {}\", path);\n}","handlingStrategy":"try-catch","validationCode":"// pre-check existence via listing\nList<Metadata> existing = gcsUtil.expand(GcsPath.fromUri(dirPattern));\nboolean present = existing.stream()\n    .anyMatch(m -> m.resourceId().toString().equals(path.toString()));","typeGuard":null,"tryCatchPattern":"try {\n  Blob blob = gcsUtil.getBlob(GcsPath.fromUri(uri));\n} catch (FileNotFoundException e) {\n  // treat as missing: skip, substitute default, or surface config error\n}","preventionTips":["Resolve file paths from fresh directory listings instead of stale cached values","Validate templated path options before pipeline start","Use expand()/match() on globs rather than calling fileSize on possibly-absent exact paths"],"tags":["gcs","file-not-found","java","apache-beam"],"backgroundTag":"file-not-found","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"}