influxdata/influxdb · error · OrgBucketMappingError

invalid namespace name

Error message

invalid namespace name: {0}

What it means

OrgBucketMappingError::InvalidNamespaceName is returned when converting an org/bucket string pair into a NamespaceName fails because one of the strings violates namespace name validation rules. The underlying NamespaceNameError (from the #[from] conversion) is embedded and displayed as "invalid namespace name: {0}". The library throws it because org and bucket identifiers must be valid namespace names to be used as a namespace.

Solutions

  1. Inspect the embedded NamespaceNameError in the message to see whether it was a length or character problem.
  2. Rename the org/bucket to contain only allowed characters (alphanumeric, '-', '_', etc.) and within the length constraint.
  3. If you cannot change the name, create a valid namespace and map your writes to it instead of using the raw bucket string.
  4. Sanitize/validate org and bucket inputs at your application boundary before calling the library.

Example fix

// before
let ns = NamespaceName::from_org_bucket("my org", "bucket/1")?; // invalid chars
// after
let ns = NamespaceName::from_org_bucket("my-org", "bucket-1")?;
Defensive patterns

Strategy: validation

Validate before calling

fn is_valid_namespace_name(s: &str) -> bool {
    !s.is_empty()
        && (4..=64).contains(&s.len())
        && s.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')
}
// call before: is_valid_namespace_name(org) && is_valid_namespace_name(bucket)

Try / catch

match NamespaceName::from_org_bucket(org, bucket) {
    Ok(ns) => use(ns),
    Err(OrgBucketMappingError::InvalidNamespaceName(e)) => {
        log::error!("org/bucket failed name validation: {e}");
        sanitize_and_retry(org, bucket)
    }
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling the org/bucket to NamespaceName mapping (e.g. try_from(&str, &str) style constructors) with an org or bucket string that fails NamespaceName validation: too short/long or containing disallowed characters.

Common situations: InfluxDB 3.0 users writing to a database name containing characters like '/', ':' or spaces, or an overly long bucket name in the v1 write path where org/bucket map to a namespace.

Related errors


AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19). Data as JSON: /api/errors/90eb9c5f81f9fbec. Report an issue: GitHub.

Appendix: source

Thrown at core/data_types/src/namespace_name.rs:23

/// Length constraints for a [`NamespaceName`] name.
///
/// A `RangeInclusive` is a closed interval, covering [1, 64]
const LENGTH_CONSTRAINT: RangeInclusive<usize> = 1..=64;

/// Allowlist of chars for a [`NamespaceName`] name.
///
/// '/' | '_' | '-' are utilized by the platforms.
fn is_allowed(c: char) -> bool {
    c.is_alphanumeric() || matches!(c, '/' | '_' | '-')
}

/// Errors returned when attempting to construct a [`NamespaceName`] from an org
/// & bucket string pair.
#[derive(Debug, Error)]
pub enum OrgBucketMappingError {
    /// An error returned when the org, or bucket string contains invalid
    /// characters.
    #[error("invalid namespace name: {0}")]
    InvalidNamespaceName(#[from] NamespaceNameError),

    /// Either the org, or bucket is an empty string.
    #[error("missing org/bucket value")]
    NoOrgBucketSpecified,
}

/// [`NamespaceName`] name validation errors.
#[derive(Debug, Error)]
pub enum NamespaceNameError {
    /// The provided namespace name does not fall within the valid length of a
    /// namespace.
    #[error(
        "namespace name {} length must be between {} and {} characters",
        name,
        LENGTH_CONSTRAINT.start(),
        LENGTH_CONSTRAINT.end()
    )]

View on GitHub (pinned to 06200ef96b)