{"record":{"id":"e2d8ac1b09d534db","repo":"influxdata/influxdb","slug":"attempted-to-create-a-resource-that-already-exists","errorCode":null,"errorMessage":"attempted to create a resource that already exists","messagePattern":"attempted to create a resource that already exists","errorType":"validation","errorClass":"CatalogError","httpStatus":409,"severity":"error","filePath":"influxdb3_catalog/src/error.rs","lineNumber":50,"sourceCode":"}\n\nuse crate::{\n    channel::SubscriptionError, format::FeatureLevel, format::FormatError,\n    log::versions::v4::StorageMode, object_store::ObjectStoreCatalogError,\n};\n\n#[derive(Debug, thiserror::Error)]\npub enum CatalogError {\n    #[error(transparent)]\n    Enterprise(#[from] EnterpriseCatalogError),\n\n    #[error(\"object store error: {0:?}\")]\n    ObjectStore(#[from] ObjectStoreCatalogError),\n\n    #[error(\"catalog format error: {0}\")]\n    Format(#[from] FormatError),\n\n    #[error(\"attempted to create a resource that already exists\")]\n    AlreadyExists,\n\n    #[error(\"the requested resource was not found: {0}\")]\n    NotFound(String),\n\n    #[error(\"attempted to modify resource that was already deleted: {0}\")]\n    AlreadyDeleted(String),\n\n    /// Request is idempotent: no catalog state would change.\n    #[error(\"no catalog changes to apply: {details}\")]\n    NoCatalogChange { details: String },\n\n    /// Request is invalid.\n    #[error(\"catalog internal error: {details}\")]\n    Internal { details: String },\n\n    #[error(\n        \"persisted catalog checkpoint sequence {checkpoint_sequence} is ahead of live catalog sequence {live_sequence}\"","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_catalog/src/error.rs#L32-L68","documentation":"CatalogError::AlreadyExists is thrown when an API attempts to create a catalog resource (database, table, token, trigger, cache, etc.) whose name/identifier already exists. It is a typed variant so callers can distinguish duplicate creation from other failures. The catalog treats resource names as unique within their scope.","triggerScenarios":"POST /api/v3/configure/database with an existing database name; creating a table with a name already in the database; duplicate token, distinct-cache, last-cache, or trigger creation calls; concurrent create requests racing for the same name.","commonSituations":"Idempotency-unaware retry logic resending a create request; scripts run twice; two operator processes creating the same resource concurrently; case/name collisions.","solutions":["Check existence first (GET the resource) or handle this variant as success for idempotent flows","Pick a unique name or delete the existing resource before recreating","Serialize create operations or rely on the API's idempotency semantics","Catch CatalogError::AlreadyExists specifically and branch on it"],"exampleFix":"// before\nlet db = catalog.create_database(\"mydb\").await?;\n// after\nmatch catalog.create_database(\"mydb\").await {\n    Ok(db) => db,\n    Err(CatalogError::AlreadyExists) => catalog.db(\"mydb\").expect(\"exists\"),\n    Err(e) => return Err(e.into()),\n}","handlingStrategy":"try-catch","validationCode":"// Rust: check existence before create\nif catalog.db(\"mydb\").is_ok() {\n    eprintln!(\"database mydb already exists\");\n}","typeGuard":"fn is_already_exists(err: &CatalogError) -> bool {\n    matches!(err, CatalogError::AlreadyExists)\n}","tryCatchPattern":"match catalog.create_database(\"mydb\").await {\n    Ok(db) => db,\n    Err(CatalogError::AlreadyExists) => /* idempotent path */ catalog.db(\"mydb\").unwrap(),\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Design create calls to be idempotent (treat AlreadyExists as success)","Avoid duplicate concurrent creation jobs","Use unique, convention-driven resource names","Check existence before destructive recreate"],"tags":["duplicate","catalog","conflict"],"backgroundTag":"file-already-exists","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}