{"record":{"id":"9b7035215df0227c","repo":"floci-io/floci","slug":"validationexception-9b7035","errorCode":"ValidationException","errorMessage":"An export with the name {name} already exists.","messagePattern":"An export with the name (.+?) already exists\\.","errorType":"exception","errorClass":"AwsException","httpStatus":400,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/bcmdataexports/BcmDataExportsService.java","lineNumber":85,"sourceCode":"                        new TypeReference<Map<String, ExportExecution>>() {}),\n                regionResolver);\n    }\n\n    BcmDataExportsService(StorageBackend<String, Export> exportStore,\n                          StorageBackend<String, ExportExecution> executionStore,\n                          RegionResolver regionResolver) {\n        this.exportStore = exportStore;\n        this.executionStore = executionStore;\n        this.regionResolver = regionResolver;\n    }\n\n    /** {@code CreateExport} — creates and persists a new {@link Export}. */\n    public Export createExport(Export incoming, Map<String, String> resourceTags, String region) {\n        validateExport(incoming);\n        String accountId = regionResolver.getAccountId();\n\n        if (findByName(incoming.getName()) != null) {\n            throw new AwsException(\"ValidationException\",\n                    \"An export with the name \" + incoming.getName() + \" already exists.\", 400);\n        }\n\n        String exportArn = buildArn(region, accountId, incoming.getName());\n        long now = System.currentTimeMillis();\n        incoming.setExportArn(exportArn);\n        incoming.setCreatedAt(now);\n        incoming.setLastUpdatedAt(now);\n        incoming.setExportStatus(\"HEALTHY\");\n        incoming.setOwnerAccountId(accountId);\n        if (resourceTags != null) {\n            incoming.setResourceTags(new HashMap<>(resourceTags));\n        }\n\n        exportStore.put(exportKey(exportArn), incoming);\n        LOG.infov(\"Created BCM export: {0} (arn={1})\", incoming.getName(), exportArn);\n        return incoming;\n    }","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/bcmdataexports/BcmDataExportsService.java#L67-L103","documentation":"Thrown by Floci's BCM Data Exports emulator from CreateExport when an export with the same Name already exists (names are unique per account, matching real AWS). createExport calls findByName over the export store before persisting and returns ValidationException (400) on collision.","triggerScenarios":"bcmDataExportsClient.createExport(r -> r.name(\"my-export\")...) twice without deleting the first export; test fixtures re-running CreateExport with fixed names against persistent storage.","commonSituations":"Integration tests with hardcoded export names against Floci in persistent/hybrid storage mode; CI re-runs without cleanup; retry logic that re-sends CreateExport after a timeout even though the first call succeeded.","solutions":["Call DeleteExport on the existing export before recreating it, or pick a unique name (add a run id/UUID suffix).","Check for the existing export first with GetExport/ListExports and reuse it when appropriate.","Make test teardown delete exports so re-runs start clean.","For retries, treat this error as 'already created' rather than failure."],"exampleFix":"// before\nbcm.createExport(r -> r.name(\"daily-cost\").dataQuery(dq).refreshCadence(rc));\n\n// after\ntry {\n    bcm.createExport(r -> r.name(\"daily-cost\").dataQuery(dq).refreshCadence(rc));\n} catch (ValidationException alreadyExists) {\n    bcm.deleteExport(r -> r.exportArn(existingArn));\n    bcm.createExport(r -> r.name(\"daily-cost\").dataQuery(dq).refreshCadence(rc));\n}","handlingStrategy":"try-catch","validationCode":"boolean exists = bcm.listExports().exports().stream()\n    .anyMatch(e -> e.name().equals(name));","typeGuard":null,"tryCatchPattern":"try {\n    bcm.createExport(req);\n} catch (software.amazon.awssdk.services.bcmdataexports.model.ValidationException e) {\n    if (e.getMessage().contains(\"already exists\")) {\n        // reuse or delete-then-recreate\n    } else { throw e; }\n}","preventionTips":["Delete exports in test teardown so fixed names are reusable.","Add a run-id suffix to export names in CI.","Treat 'already exists' as success in retry wrappers."],"tags":["bcm-data-exports","duplicate","validation","floci","java"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}