{"record":{"id":"a4cc79880d7c13dd","repo":"apache/iceberg","slug":"ecs-object-already-exists-s","errorCode":null,"errorMessage":"ECS object already exists: %s","messagePattern":"ECS object already exists: (.+?)","errorType":"exception","errorClass":"AlreadyExistsException","httpStatus":null,"severity":"error","filePath":"dell/src/main/java/org/apache/iceberg/dell/ecs/EcsOutputFile.java","lineNumber":63,"sourceCode":"  }\n\n  EcsOutputFile(\n      S3Client client, EcsURI uri, DellProperties dellProperties, MetricsContext metrics) {\n    super(client, uri, dellProperties, metrics);\n  }\n\n  /**\n   * Create an output stream for the specified location if the target object does not exist in ECS\n   * at the time of invocation.\n   *\n   * @return output stream\n   */\n  @Override\n  public PositionOutputStream create() {\n    if (!exists()) {\n      return createOrOverwrite();\n    } else {\n      throw new AlreadyExistsException(\"ECS object already exists: %s\", uri());\n    }\n  }\n\n  @Override\n  public PositionOutputStream createOrOverwrite() {\n    return EcsAppendOutputStream.create(client(), uri(), metrics());\n  }\n\n  @Override\n  public InputFile toInputFile() {\n    return new EcsInputFile(client(), uri(), dellProperties(), metrics());\n  }\n}\n","sourceCodeStart":45,"sourceCodeEnd":77,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/dell/src/main/java/org/apache/iceberg/dell/ecs/EcsOutputFile.java#L45-L77","documentation":"AlreadyExistsException from EcsOutputFile.create: this create() must not clobber, and an object already exists at the target ECS URI (the exists() check passed into this branch). The %s is the EcsURI; callers wanting to overwrite should call createOrOverwrite() instead.","triggerScenarios":"Calling outputFile.create() when an object at the URI already exists, e.g. writing to the same data/metadata path twice.","commonSituations":"Job retry writing the same file path, non-unique filename generation (e.g. using timestamps with low resolution), intentional overwrite attempted via create() instead of createOrOverwrite().","solutions":["Use createOrOverwrite() when overwriting is intended","Generate unique file names (UUID) per write","Check existence with exists() first or catch AlreadyExistsException"],"exampleFix":"// before\noutputFile.create();\n// after\noutputFile.createOrOverwrite(); // or catch AlreadyExistsException","handlingStrategy":"try-catch","validationCode":"if (!outputFile.exists()) { stream = outputFile.create(); } else { stream = outputFile.createOrOverwrite(); }","typeGuard":null,"tryCatchPattern":"try { stream = outputFile.create(); } catch (AlreadyExistsException e) { stream = outputFile.createOrOverwrite(); }","preventionTips":["Use createOrOverwrite when overwriting is acceptable","Generate unique file names (UUID) for each write","Avoid retrying failed writes to the same fixed path with create()"],"tags":["ecs","file-write","already-exists"],"backgroundTag":"file-already-exists","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}