{"record":{"id":"c878122b8ec3796f","repo":"influxdata/influxdb","slug":"database-not-found-db-name-lib","errorCode":null,"errorMessage":"database not found {db_name}","messagePattern":"database not found (.+?)","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"influxdb3_server/src/lib.rs","lineNumber":69,"sourceCode":"use trace_http::metrics::{MetricFamily, RequestMetrics};\nuse trace_http::tower::{ServiceProtocol, TraceLayer};\nuse unified_service::{RemoteAddrLayer, UnifiedService};\n\npub const PRODUCT_NAME: &str = \"InfluxDB 3 Core\";\npub const INFLUXDB3_BUILD: &str = \"Core\";\n\n/// Version string combining the product name, [`influxdb3_process::INFLUXDB3_VERSION`], and [`influxdb3_process::INFLUXDB3_GIT_HASH`].\npub static VERSION_STRING: LazyLock<String> = LazyLock::new(|| build_version_string(PRODUCT_NAME));\n\n#[derive(Debug, Error)]\npub enum Error {\n    #[error(\"hyper error: {0}\")]\n    Hyper(#[from] hyper::Error),\n\n    #[error(\"http error: {0}\")]\n    Http(#[from] Box<http::Error>),\n\n    #[error(\"database not found {db_name}\")]\n    DatabaseNotFound { db_name: String },\n\n    #[error(\"datafusion error: {0}\")]\n    DataFusion(#[from] datafusion::error::DataFusionError),\n\n    #[error(\"influxdb3_write error: {0}\")]\n    InfluxDB3Write(#[from] influxdb3_write::Error),\n\n    #[error(\"from hex error: {0}\")]\n    FromHex(#[from] hex::FromHexError),\n\n    #[error(\"io error: {0}\")]\n    Io(#[from] std::io::Error),\n\n    #[error(\"tls config error: {0}\")]\n    TlsConfig(String),\n\n    #[error(\"rustls error: {0}\")]","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_server/src/lib.rs#L51-L87","documentation":"The DatabaseNotFound variant of influxdb3_server::Error: a query or write referenced a database name that does not exist in the catalog. The server cannot resolve the requested database, so the operation is rejected with the offending db_name in the message.","triggerScenarios":"Querying (POST /api/v3/query, SQL or InfluxQL) with a database parameter that was never created; writing to a database before creating it when auto-creation is disabled; referencing a database that was deleted or that belongs to a different org/instance.","commonSituations":"Typo in the db name in a client config; environment mismatch (querying a staging database on a production server); database dropped between writes and queries; connection pointed at the wrong InfluxDB instance or port.","solutions":["Verify the exact database name with the server's catalog (e.g. SHOW DATABASES / the list-databases API)","Create the database first (POST /api/v3/configure/database) before querying/writing to it","Confirm the client is pointed at the intended server instance and organization"],"exampleFix":"// before\nclient.query_sql(db=\"sensors-prod\", \"SELECT * FROM cpu\").await?; // db may not exist\n// after\nlet dbs = client.list_databases().await?;\nanyhow::ensure!(dbs.contains(&\"sensors-prod\".into()), \"create the database first\");\nclient.query_sql(\"sensors-prod\", \"SELECT * FROM cpu\").await?;","handlingStrategy":"validation","validationCode":"let existing: Vec<String> = client.list_databases().await?;\nif !existing.contains(&db_name.to_string()) {\n    return Err(format!(\"database '{db_name}' does not exist; create it first\"));\n}","typeGuard":null,"tryCatchPattern":"match err {\n    ServerError::DatabaseNotFound { db_name } => {\n        eprintln!(\"db '{db_name}' missing — creating it and retrying\");\n        client.create_database(&db_name).await?;\n    }\n    _ => return Err(err),\n}","preventionTips":["Centralize db names in config instead of string literals at call sites","Create databases as an explicit provisioning step in deployment","Match server instance/environment before issuing queries"],"tags":["database","not-found","query"],"backgroundTag":"database-query-failed","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"}