{"record":{"id":"65bb7b0d4777532b","repo":"influxdata/influxdb","slug":"db-name-cannot-be-empty","errorCode":null,"errorMessage":"db name cannot be empty","messagePattern":"db name cannot be empty","errorType":"validation","errorClass":"ValidateDbNameError","httpStatus":null,"severity":"error","filePath":"influxdb3_server/src/http.rs","lineNumber":2434,"sourceCode":"// retention policy name; we support those combined with a forward slash so\n// 255*2+1.\nconst MAXIMUM_DATABASE_NAME_LENGTH: usize = 511;\n\n#[derive(Clone, Copy, Debug, thiserror::Error)]\npub enum ValidateDbNameError {\n    #[error(\n        \"invalid character in database or rp name: must be ASCII, \\\n        containing only letters, numbers, underscores, or hyphens\"\n    )]\n    InvalidChar,\n    #[error(\"db name did not start with a number or letter\")]\n    InvalidStartChar,\n    #[error(\n        \"db name with invalid retention policy, if providing a \\\n        retention policy name, must be of form '<db_name>/<rp_name>'\"\n    )]\n    InvalidRetentionPolicy,\n    #[error(\"db name cannot be empty\")]\n    Empty,\n    #[error(\"db name too long: max {}\", MAXIMUM_DATABASE_NAME_LENGTH)]\n    NameTooLong,\n}\n\nasync fn record_batch_stream_to_body(\n    mut stream: Pin<Box<dyn RecordBatchStream + Send>>,\n    format: QueryFormat,\n) -> Result<ResponseBody, Error> {\n    match format {\n        QueryFormat::Pretty => {\n            let batches = stream.try_collect::<Vec<RecordBatch>>().await?;\n            Ok(bytes_to_response_body(Bytes::from(format!(\n                \"{}\",\n                pretty::pretty_format_batches(&batches)?\n            ))))\n        }\n        QueryFormat::Parquet => {","sourceCodeStart":2416,"sourceCodeEnd":2452,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_server/src/http.rs#L2416-L2452","documentation":"Variant `Empty` of `ValidateDbNameError` in influxdb3_server/src/http.rs. The database name supplied to the request was an empty string, which cannot identify any database, so validation fails immediately.","triggerScenarios":"Calling write/query endpoints with `?db=` (empty value), an unbound template variable, or a config value that resolves to an empty string.","commonSituations":"Environment variables like INFLUX_DB unset causing empty interpolation; client SDK configured with an empty database field; query builders that omit the db parameter value.","solutions":["Provide a non-empty database name in the request (e.g. `?db=mydb`)","Check the client configuration/env so the database value is actually populated","Add a client-side `if (!db) throw` guard before constructing the request"],"exampleFix":"// before\ncurl 'host/api/v3/write?db=' --data 'm v=1'\n// after\ncurl 'host/api/v3/write?db=mydb' --data 'm v=1'","handlingStrategy":"validation","validationCode":"function requireDb(db) {\n  if (typeof db !== 'string' || db.length === 0) throw new Error('database name is required and cannot be empty');\n}","typeGuard":"const hasDb = (cfg) => typeof cfg?.database === 'string' && cfg.database.length > 0;","tryCatchPattern":"try {\n  return await api.write(db, data);\n} catch (e) {\n  if (String(e.message).includes('db name cannot be empty')) {\n    throw new ConfigError('database name missing; check client config / INFLUX_DB env');\n  }\n  throw e;\n}","preventionTips":["Fail fast at client construction if the database setting is empty","Verify env vars (e.g. INFLUX_DB) are set in all deployment environments"],"tags":["database","naming","validation","empty-value"],"backgroundTag":"empty-required-field","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"}