{"record":{"id":"c9edf4540aa9e5ed","repo":"influxdata/influxdb","slug":"namespace-name-length-must-be-between-and-characters","errorCode":null,"errorMessage":"namespace name {} length must be between {} and {} characters","messagePattern":"namespace name (.+?) length must be between (.+?) and (.+?) characters","errorType":"validation","errorClass":"NamespaceNameError","httpStatus":null,"severity":"error","filePath":"core/data_types/src/namespace_name.rs","lineNumber":36,"sourceCode":"/// & bucket string pair.\n#[derive(Debug, Error)]\npub enum OrgBucketMappingError {\n    /// An error returned when the org, or bucket string contains invalid\n    /// characters.\n    #[error(\"invalid namespace name: {0}\")]\n    InvalidNamespaceName(#[from] NamespaceNameError),\n\n    /// Either the org, or bucket is an empty string.\n    #[error(\"missing org/bucket value\")]\n    NoOrgBucketSpecified,\n}\n\n/// [`NamespaceName`] name validation errors.\n#[derive(Debug, Error)]\npub enum NamespaceNameError {\n    /// The provided namespace name does not fall within the valid length of a\n    /// namespace.\n    #[error(\n        \"namespace name {} length must be between {} and {} characters\",\n        name,\n        LENGTH_CONSTRAINT.start(),\n        LENGTH_CONSTRAINT.end()\n    )]\n    LengthConstraint {\n        /// The user-provided namespace that failed validation.\n        name: String,\n    },\n\n    /// The provided namespace name contains an unacceptable character.\n    #[error(\n        \"namespace name '{}' contains invalid character, character number {} \\\n        is not allowed\",\n        name,\n        bad_char_offset\n    )]\n    BadChars {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/data_types/src/namespace_name.rs#L18-L54","documentation":"NamespaceNameError::LengthConstraint is returned when a namespace name's length falls outside the allowed range defined by LENGTH_CONSTRAINT. The message reports the provided name plus the minimum and maximum allowed lengths. The library enforces this to keep namespace identifiers within storage and URL-safety bounds.","triggerScenarios":"Calling NamespaceName::new (or try_from(&str)) with a name shorter than LENGTH_CONSTRAINT.start() or longer than LENGTH_CONSTRAINT.end(), e.g. an empty-derived name or a very long bucket name used as a database name.","commonSituations":"Auto-generated database names from long bucket/team prefixes exceeding the max length; empty names after trimming; programmatic name generation without length checks.","solutions":["Read the reported min/max in the message and shorten (or lengthen) the name to fit.","Truncate long programmatic names to the maximum length before constructing the NamespaceName.","Hash or abbreviate long identifiers instead of concatenating full prefixes.","Pre-validate name.len() against the length bounds in your code before calling the API."],"exampleFix":"// before\nlet ns = NamespaceName::new(&very_long_name)?; // may exceed max length\n// after\nlet name = &very_long_name[..very_long_name.len().min(MAX_LEN)];\nlet ns = NamespaceName::new(name)?;","handlingStrategy":"validation","validationCode":"const MIN: usize = 1; // check LENGTH_CONSTRAINT bounds from data_types\nconst MAX: usize = 64;\nfn name_length_ok(s: &str) -> bool {\n    (MIN..=MAX).contains(&s.chars().count())\n}","typeGuard":null,"tryCatchPattern":"match NamespaceName::new(name) {\n    Ok(ns) => use(ns),\n    Err(NamespaceNameError::LengthConstraint { name }) => {\n        log::error!(\"'{name}' length out of allowed range; truncating\");\n        NamespaceName::new(&truncate(name))\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Truncate or hash long generated names to the documented maximum before use.","Reject empty strings early since they fall below the minimum length.","Centralize namespace-name creation in one helper that enforces length bounds."],"tags":["rust","validation","length-limit","influxdb"],"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"}