influxdata/influxdb · error · ValidationError

invalid tag name value in partition template

Error message

invalid tag name value in partition template: {0}

What it means

This error is returned when a partition template defines a `TagValue` or `Bucket` part whose tag name is invalid. Tag names must satisfy identifier rules (e.g., non-empty, valid characters, collision-free within the template), and the library rejects the template at validation time. The invalid tag name is carried in the `String` payload.

Solutions

  1. Correct the tag name in the error payload to a valid identifier (non-empty, allowed characters only, e.g. letters/digits/underscores)
  2. Ensure the name matches an existing column/tag in the schema you intend to partition on
  3. Sanitize or validate user-supplied tag names before constructing the template
  4. If migrating templates from another system, rename parts that use characters this library disallows

Example fix

// before
builder.add_tag_part(""); // invalid: empty tag name
// after
builder.add_tag_part("region");
Defensive patterns

Strategy: validation

Validate before calling

fn is_valid_tag_name(name: &str) -> bool {
    !name.is_empty()
        && name.chars().all(|c| c.is_ascii_alphanumeric() || c == '_')
}
if !is_valid_tag_name(&tag) { return Err(format!("invalid tag name: {:?}", tag)); }

Type guard

fn valid_tag_part(name: &str) -> Option<&str> {
    is_valid_tag_name(name).then_some(name)
}

Try / catch

let template = builder.build().map_err(|e| match e {
    ValidationError::InvalidTagValue(name) => anyhow!("tag name {:?} is invalid: use non-empty identifier-safe characters", name),
    other => anyhow!(other),
})?;

Prevention

When it happens

Trigger: Calling `PartitionTemplateBuilder::add_tag_part(name)` or `add_bucket_part(name, ...)` (or validating a proto template whose part is `TagValue`/`Bucket`) with a name failing tag-name validation — empty string, illegal characters, whitespace, or control characters.

Common situations: Config-driven template generation passing empty or placeholder names; column names containing spaces/special characters from other systems; user DDL input with typos or quoting mistakes; names truncated or mangled by upstream parsing.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


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

Appendix: source

Thrown at core/data_types/src/partition_template.rs:229

    TooManyParts {
        /// The number of template parts that were present in the user-provided custom partition
        /// template.
        specified: usize,
    },

    /// The partition template defines a [`TimeFormat`] part, but the
    /// provided strftime formatter is invalid.
    ///
    /// [`TimeFormat`]: [`proto::template_part::Part::TimeFormat`]
    #[error("invalid strftime format in partition template: {0}")]
    InvalidStrftime(String),

    /// The partition template defines a [`TagValue`] part or [`Bucket`] part,
    /// but the provided tag name value is invalid.
    ///
    /// [`TagValue`]: [`proto::template_part::Part::TagValue`]
    /// [`Bucket`]: [`proto::template_part::Part::Bucket`]
    #[error("invalid tag name value in partition template: {0}")]
    InvalidTagValue(String),

    /// The partition template defines a [`Bucket`] part, but the provided
    /// number of buckets is invalid.
    ///
    /// [`Bucket`]: [`proto::template_part::Part::Bucket`]
    #[error(
        "number of buckets in partition template must be in range \
        [{ALLOWED_BUCKET_QUANTITIES:?}), number specified: {0}"
    )]
    InvalidNumberOfBuckets(u32),

    /// The partition template defines a [`TagValue`] or [`Bucket`] part
    /// which repeats a tag name used in another [`TagValue`] or [`Bucket`] part.
    /// This is not allowed
    ///
    /// [`TagValue`]: [`proto::template_part::Part::TagValue`]
    /// [`Bucket`]: [`proto::template_part::Part::Bucket`]

View on GitHub (pinned to 06200ef96b)