{"record":{"id":"445944adbbdd293e","repo":"influxdata/influxdb","slug":"database-name-length-must-be-between-and-characters","errorCode":null,"errorMessage":"database name {} length must be between {} and {} characters","messagePattern":"database name (.+?) length must be between (.+?) and (.+?) characters","errorType":"validation","errorClass":"DatabaseNameError","httpStatus":null,"severity":"error","filePath":"influxdb3_types/src/database_name.rs","lineNumber":54,"sourceCode":"}\n\nimpl Display for TruncatedString {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        write!(f, \"{}\", self.inner())\n    }\n}\n\n/// Allowlist of chars for a [`DatabaseName`].\nfn is_allowed(c: char) -> bool {\n    c.is_alphanumeric() || matches!(c, '/' | '_' | '-')\n}\n\n/// [`DatabaseName`] name validation errors.\n#[derive(Debug, Error)]\npub enum DatabaseNameError {\n    /// The provided database name does not fall within the valid length of a\n    /// database.\n    #[error(\n        \"database name {} length must be between {} and {} characters\",\n        name,\n        LENGTH_CONSTRAINT.start(),\n        LENGTH_CONSTRAINT.end()\n    )]\n    LengthConstraint {\n        /// The user-provided database that failed validation.\n        name: TruncatedString,\n    },\n\n    /// The provided database name contains an unacceptable character.\n    #[error(\n        \"database name '{}' contains invalid character, character number {} \\\n        is not allowed\",\n        name,\n        bad_char_offset\n    )]\n    BadChars {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_types/src/database_name.rs#L36-L72","documentation":"DatabaseNameError::LengthConstraint is thrown by influxdb3_types::database_name validation when a database name is shorter than LENGTH_CONSTRAINT.start() or longer than LENGTH_CONSTRAINT.end(). The error carries the rejected name (as TruncatedString) and formats the allowed min/max bounds from the constraint range. It enforces the documented size limit for InfluxDB 3 database identifiers.","triggerScenarios":"Calling any API that validates a database name (e.g. DatabaseName::parse / from_str) with a name whose character count falls outside LENGTH_CONSTRAINT, such as an empty or 1-char name or a very long name.","commonSituations":"Auto-generating database names from user input or hostnames, template substitutions producing empty names, truncation/concatenation logic exceeding the max length, defaults not set so an empty string is passed.","solutions":["Shorten or lengthen the database name so its character count is within the allowed range reported in the message","Trim whitespace/empty prefixes and check the name is non-empty before calling the API","Generate a shorter unique name (hash or prefix truncation) for programmatic names"],"exampleFix":"// before\nlet db = DatabaseName::parse(\"\")?; // too short\n// after\nlet name = if raw.is_empty() { \"default\" } else { raw.as_str() };\nlet db = DatabaseName::parse(name)?;","handlingStrategy":"validation","validationCode":"fn valid_db_name_len(name: &str) -> bool {\n    let n = name.chars().count();\n    (MIN..=MAX).contains(&n) // use the bounds from LENGTH_CONSTRAINT\n}","typeGuard":"fn is_valid_db_name(name: &str) -> bool {\n    !name.is_empty() && name.chars().count() >= 1 && name.chars().count() <= 255\n}","tryCatchPattern":null,"preventionTips":["Validate length at the input boundary before creating databases","Never allow empty defaults for database name config","Truncate generated names to the max bound with a hash suffix"],"tags":["validation","database","rust"],"backgroundTag":"value-out-of-range","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"}