{"record":{"id":"014140f924bfd8db","repo":"apache/hadoop","slug":"must-specify-either-create-or-overwrite","errorCode":null,"errorMessage":"Must specify either create or overwrite","messagePattern":"Must specify either create or overwrite","errorType":"exception","errorClass":"PathIOException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/CreateFileBuilder.java","lineNumber":167,"sourceCode":"      String key = option.getKey();\n      if (key.startsWith(headerPrefix) && key.length() > prefixLen) {\n        headers.put(key.substring(prefixLen), option.getValue());\n      }\n    }\n\n    // and add the mimetype\n    if (options.get(FS_OPTION_CREATE_CONTENT_TYPE, null) != null)  {\n      headers.put(CONTENT_TYPE, options.get(FS_OPTION_CREATE_CONTENT_TYPE, null));\n    }\n\n    EnumSet<CreateFlag> flags = getFlags();\n    if (flags.contains(CreateFlag.APPEND)) {\n      throw new UnsupportedOperationException(\"Append is not supported\");\n    }\n\n    if (!flags.contains(CreateFlag.CREATE) &&\n        !flags.contains(CreateFlag.OVERWRITE)) {\n      throw new PathIOException(path.toString(),\n          \"Must specify either create or overwrite\");\n    }\n\n    // build the other switches\n    if (isRecursive()) {\n      createFileSwitches.add(Recursive);\n    }\n    if (Performance.isEnabled(options)) {\n      createFileSwitches.add(Performance);\n    }\n    if (CreateMultipart.isEnabled(options)) {\n      createFileSwitches.add(CreateMultipart);\n    }\n    if (ConditionalOverwrite.isEnabled(options)) {\n      createFileSwitches.add(ConditionalOverwrite);\n    }\n    // etag is a string so is checked for then extracted.\n    final String etag = options.get(FS_OPTION_CREATE_CONDITIONAL_OVERWRITE_ETAG, null);","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/CreateFileBuilder.java#L149-L185","documentation":"Error \"Must specify either create or overwrite\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/CreateFileBuilder.java:167 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set either create(true) or overwrite(true) on the create file builder."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}