{"record":{"id":"ac3ea9785b00f2e5","repo":"influxdata/influxdb","slug":"db-name-too-long-max","errorCode":null,"errorMessage":"db name too long: max {}","messagePattern":"db name too long: max (.+?)","errorType":"validation","errorClass":"ValidateDbNameError","httpStatus":null,"severity":"error","filePath":"influxdb3_server/src/http.rs","lineNumber":2436,"sourceCode":"const 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 => {\n            // Grab the first batch so that we can get the schema\n            let Some(batch) = stream.next().await.transpose()? else {","sourceCodeStart":2418,"sourceCodeEnd":2454,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_server/src/http.rs#L2418-L2454","documentation":"This error comes from the write path's database-name validation enum in influxdb3_server: the supplied database name exceeds MAXIMUM_DATABASE_NAME_LENGTH characters. InfluxDB enforces a hard cap on database (bucket) identifier length when validating names before creating or writing to a database. The request is rejected before any data is stored.","triggerScenarios":"Calling the InfluxDB 3 write API (e.g. POST /api/v3/write_lp or /write) with a `db` parameter longer than the maximum allowed length; programmatic database creation where a name is derived from user input or a long hostname/UUID without length checks.","commonSituations":"Auto-generating database names from UUIDs, hostnames, or concatenating tenant+environment prefixes; misconfigured SDK defaults that append long suffixes; migrating from systems with laxer naming limits.","solutions":["Shorten the database name to be at most MAXIMUM_DATABASE_NAME_LENGTH characters (use a hash or abbreviation of the intended name)","Validate the name length client-side before issuing the write/create call","If the name must encode more information, move the extra detail into tags/fields rather than the db name"],"exampleFix":"// before\nlet db = format!(\"{}_{}_{}\", tenant, env, hostname); // may exceed limit\nclient.write_lp(db, &line_protocol).await?;\n// after\nconst MAX_DB_NAME: usize = 64;\nlet db = format!(\"{}_{}\", tenant, env);\nassert!(db.len() <= MAX_DB_NAME, \"db name too long\");\nclient.write_lp(db, &line_protocol).await?;","handlingStrategy":"validation","validationCode":"const MAX_DB_NAME: usize = 64; // matches MAXIMUM_DATABASE_NAME_LENGTH\nif db_name.is_empty() || db_name.len() > MAX_DB_NAME {\n    return Err(format!(\"db name must be 1..={} chars\", MAX_DB_NAME));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check name length before every create/write call","Derive names from fixed prefixes plus short hashes, not raw hostnames or full UUIDs","Keep db names in a shared constant/config so all environments use validated names"],"tags":["validation","database","naming"],"backgroundTag":"invalid-identifier-format","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"}