{"record":{"id":"e965cd143162db6b","repo":"apache/hadoop","slug":"parent-is-a-file","errorCode":null,"errorMessage":"parent + \" is a file\"","messagePattern":"parent \\+ \" is a file\"","errorType":"exception","errorClass":"FileAlreadyExistsException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BaiduBosFileSystem.java","lineNumber":232,"sourceCode":"   * @param replication the replication factor\n   * @param blockSize the block size\n   * @param progress for reporting progress\n   * @return an output stream to write to\n   * @throws IOException if an I/O error occurs\n   */\n  @Override\n  public FSDataOutputStream createNonRecursive(Path f,\n      FsPermission permission, boolean overwrite,\n      int bufferSize, short replication, long blockSize,\n      Progressable progress) throws IOException {\n    Path absolutePath = makeAbsolute(f);\n    Path parent = absolutePath.getParent();\n\n    if (parent != null && !parent.isRoot()) {\n      try {\n        FileStatus parentStatus = getFileStatus(parent);\n        if (!parentStatus.isDirectory()) {\n          throw new FileAlreadyExistsException(\n              parent + \" is a file\");\n        }\n      } catch (FileNotFoundException e) {\n        throw new FileNotFoundException(\n            \"Parent directory doesn't exist: \" + parent);\n      }\n    }\n\n    return create(f, permission, overwrite, bufferSize,\n        replication, blockSize, progress);\n  }\n\n  /**\n   * Create a file non-recursively with CreateFlag set.\n   *\n   * @param f the file name to create\n   * @param permission the permission to set\n   * @param flags creation flags","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BaiduBosFileSystem.java#L214-L250","documentation":"TypedBytesInput.read() interprets the next byte of the stream as a typed-bytes type code and dispatches to the matching reader. Codes 0-10 map to the core types, MARKER (255) returns null, 50-200 are treated as application-specific byte payloads, and anything else hits the else branch throwing RuntimeException 'unknown type'. Hitting it means the stream is not aligned on a typed-bytes record — you are reading garbage, not that the type is merely unsupported.","triggerScenarios":"Calling TypedBytesInput.read() (directly or via TypedBytesRecordReader/typed-bytes streaming pipes) on a stream that is out of sync: after partially consuming a record, after mixing raw text and typed-bytes modes, or when the upstream writer did not emit typed bytes at all (e.g. -io typedbytes missing on one side).","commonSituations":"Streaming jobs where mapper output is typed bytes but the reducer is a plain script (or vice versa) because -io typedbytes was set on only one command; deserializing a file that was never typed-bytes encoded; a Python/Ruby streaming script printing raw strings into a typed-bytes channel; version drift where a peer emits a code outside 0-10/50-200/255.","solutions":["Make both ends of the pipe agree on the format: pass -io typedbytes to every streaming stage (mapper, combiner, reducer) so both write and read typed bytes.","Confirm the data source is genuinely typed-bytes encoded before wrapping it in TypedBytesInput; if it is raw text, use Text/LineReader-based readers instead.","If you control the protocol, confine custom codes to the 50-200 application-specific range, which read() accepts as raw Buffer payloads.","Wrap per-record reads in a small try/catch that logs the offending byte (mark/reset the stream) to identify where desynchronization starts."],"exampleFix":"# before (bash streaming: only one side typed)\nhadoop jar streaming.jar -mapper my_mapper.py -io typedbytes -reducer 'wc -l' ...\n\n# after\nhadoop jar streaming.jar -mapper my_mapper.py -io typedbytes \\\n  -reducer my_reducer.py -io typedbytes ...","handlingStrategy":"try-catch","validationCode":"// peek the type code before committing to read()\nin.mark(1);\nint code = in.readUnsignedByte();\nin.reset();\nboolean known = (0 <= code && code <= 10) || code == 255 || (50 <= code && code <= 200);\nif (!known) throw new IOException(\"not a typed-bytes stream at offset ...\");","typeGuard":null,"tryCatchPattern":"try {\n  Object o = tIn.read();\n} catch (RuntimeException e) {\n  if (e.getMessage().equals(\"unknown type\")) {\n    throw new IOException(\"typed-bytes stream desynchronized\", e); // treat as corruption, not retryable\n  }\n  throw e;\n}","preventionTips":["Set -io typedbytes on every streaming stage or none.","Never interleave raw reads with TypedBytesInput on the same stream.","Keep custom type codes inside 50-200."],"tags":["hadoop","typedbytes","serialization","unknown-type","streaming"],"backgroundTag":"deserialization-type-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}