{"record":{"id":"26699b9f6ecb7f5e","repo":"apache/hadoop","slug":"object-s-doesn-t-exit","errorCode":null,"errorMessage":"Object %s doesn't exit","messagePattern":"Object (.+?) doesn't exit","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-tos/src/main/java/org/apache/hadoop/fs/tosfs/object/tos/TOS.java","lineNumber":252,"sourceCode":"    this.client = client;\n  }\n\n  private void checkAvailableClient() {\n    Preconditions.checkState(client != null,\n        \"Encountered uninitialized ObjectStorage, call initialize(..) please.\");\n  }\n\n  @Override\n  public ObjectContent get(String key, long offset, long limit) {\n    checkAvailableClient();\n    Preconditions.checkArgument(offset >= 0, \"offset is a negative number: %s\", offset);\n\n    if (limit == 0) {\n      // Can not return empty stream when limit = 0, because the requested object might not exist.\n      if (head(key) != null) {\n        return new ObjectContent(Constants.MAGIC_CHECKSUM, EMPTY_STREAM);\n      } else {\n        throw new RuntimeException(String.format(\"Object %s doesn't exit\", key));\n      }\n    }\n\n    long end = limit < 0 ? -1 : offset + limit - 1;\n    GetObjectFactory factory = (k, startOff, endOff) -> getObject(key, startOff, endOff);\n    ChainTOSInputStream chainStream =\n        new ChainTOSInputStream(factory, key, offset, end, maxDrainBytes, maxInputStreamRetries);\n    return new ObjectContent(chainStream.checksum(), chainStream);\n  }\n\n  @Override\n  public Iterable<ObjectInfo> listDir(String key, boolean recursive) {\n    if (recursive) {\n      if (bucket().isDirectory()) {\n        // The directory bucket only support list object with delimiter = '/', so if we want to\n        // list directory recursively, we have to list each dir step by step.\n        return bfsListDir(key);\n      } else {","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-tos/src/main/java/org/apache/hadoop/fs/tosfs/object/tos/TOS.java#L234-L270","documentation":"TOS.get(key, offset, limit) special-cases limit == 0: a zero-byte range GET would not reveal whether the object exists, so it calls head(key) instead; if the object does not exist it throws RuntimeException(\"Object <key> doesn't exit\") (the message contains a typo of 'exist'). A zero-length read of a missing object is thereby converted into a not-found error.","triggerScenarios":"Reading an object with limit 0 — e.g. an empty-file read or a length-0 verification — when the key does not exist: deleted concurrently, wrong key/prefix, or a key that was never written.","commonSituations":"A concurrent delete racing a zero-length read; stale file-status caches claiming a file exists after removal; keys assembled with the wrong prefix or encoding.","solutions":["Check objectStatus/head(key) before get(key, offset, 0) and handle a null result","Catch this RuntimeException and map it to FileNotFoundException for proper Hadoop semantics","Remove the concurrent delete/read race, or accept the failure as a benign not-found signal"],"exampleFix":"// before\nObjectContent c = storage.get(key, 0, 0);\n\n// after\nif (storage.head(key) == null) {\n  throw new FileNotFoundException(key);\n}\nObjectContent c = storage.get(key, 0, 0);","handlingStrategy":"validation","validationCode":"if (storage.head(key) == null) {\n  throw new FileNotFoundException(key);\n}\nObjectContent c = storage.get(key, offset, 0);","typeGuard":null,"tryCatchPattern":"try {\n  return storage.get(key, 0, 0);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"doesn't exit\")) {\n    throw (FileNotFoundException) new FileNotFoundException(key).initCause(e);\n  }\n  throw e;\n}","preventionTips":["head() before zero-length reads","Eliminate concurrent delete/read races on the same key","Map this RuntimeException to FileNotFoundException for Hadoop-correct semantics"],"tags":["hadoop-tos","volcengine-tos","object-not-found","zero-length-read"],"backgroundTag":"object-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}