{"record":{"id":"2385d5625587813b","repo":"influxdata/influxdb","slug":"database-name-contains-invalid-character-character-number-is","errorCode":null,"errorMessage":"database name '{}' contains invalid character, character number {} is not allowed","messagePattern":"database name '(.+?)' contains invalid character, character number (.+?) is not allowed","errorType":"validation","errorClass":"DatabaseNameError","httpStatus":null,"severity":"error","filePath":"influxdb3_types/src/database_name.rs","lineNumber":66,"sourceCode":"\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 {\n        /// The zero-indexed (multi-byte) character position that failed\n        /// validation.\n        bad_char_offset: usize,\n        /// The user-provided database that failed validation.\n        name: TruncatedString,\n    },\n}\n\n/// A correctly formed database name.\n///\n/// Using this wrapper type allows the consuming code to enforce the invariant\n/// that only valid names are provided.","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_types/src/database_name.rs#L48-L84","documentation":"DatabaseNameError::BadChars is thrown when a database name contains a character that is not allowed. The error reports the offending offset (character number) within the name so the caller can locate the invalid character. Database names are restricted to a safe identifier alphabet (letters, digits, and a few punctuation characters).","triggerScenarios":"Calling database name validation (DatabaseName::parse / from_str) with names containing characters outside the allowed set, e.g. spaces, slashes, dots in a disallowed position, or unicode characters; the invalid character is at position bad_char_offset.","commonSituations":"Deriving names from URLs or file paths (containing '/'), from user input with spaces, from hostnames with underscores in disallowed spots, or passing UUIDs with hyphens when only certain punctuation is permitted.","solutions":["Remove or replace the character at the reported offset with an allowed one (e.g. '-' or '_')","Sanitize the name with a regex whitelist before validation","If names come from user input, validate/normalize them at the boundary before creating the database"],"exampleFix":"// before\nlet db = DatabaseName::parse(\"my db/v2\")?; // space and '/' invalid\n// after\nlet sanitized: String = raw.chars().map(|c| if c.is_ascii_alphanumeric() { c } else { '_' }).collect();\nlet db = DatabaseName::parse(&sanitized)?;","handlingStrategy":"validation","validationCode":"fn sanitize_name(raw: &str) -> String {\n    raw.chars().map(|c| if c.is_ascii_alphanumeric() || c == '-' || c == '_' { c } else { '_' }).collect()\n}","typeGuard":"fn has_only_allowed_chars(name: &str) -> bool {\n    name.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')\n}","tryCatchPattern":null,"preventionTips":["Whitelist-regex validate identifiers from user input","Strip path/URL separators before naming databases","Reject non-ASCII input early with a clear user-facing message"],"tags":["validation","database","rust"],"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"}