influxdata/influxdb · error · PartitionKeyError
invalid strftime format in partition template
Error message
invalid strftime format in partition template
What it means
PartitionKeyError::InvalidStrftime is returned when a partition template contains a TimeFormat part whose strftime format string cannot be compiled into a valid formatter. Key generation cannot proceed without a valid time format.
Solutions
- Validate the strftime format string when the template is configured, before ingesting data
- Fix the format spec in the partition template definition
- Test the template against a sample timestamp at config load time
Example fix
// before
let tpl = Template::parse("%Y-%m-%d %Q")?; // %Q invalid
// after
let tpl = Template::parse("%Y-%m-%dT%H%M")?; Defensive patterns
Strategy: validation
Validate before calling
// validate at config load time let fmt: strftime::Fmt = format.parse().map_err(|_| "invalid strftime format in partition template")?;
Try / catch
match make_partition_key(row, &template) {
Err(PartitionKeyError::InvalidStrftime) => reject_template(template),
Err(e) => return Err(e.into()),
Ok(key) => key,
} Prevention
- Validate partition templates when they are configured, not per-row
- Test templates against a sample timestamp at startup
When it happens
Trigger: Building partition keys for rows whose template includes Template::TimeFormat with an invalid strftime spec (e.g. stray '%', unsupported specifier).
Common situations: Typo in the partition template configuration (e.g. '%Q'); user-supplied templates from config or API that were never validated; migrating templates between libraries with different strftime subsets.
Related errors
- An unexpected error occurred in the client library
- base URL error
- Cannot parse object store config
- cannot write to a compactor-only server
- Connection error
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/e29aa71cbcdf4c66.
Report an issue: GitHub.
Appendix: source
Thrown at core/partition/src/lib.rs:38
},
};
use hashbrown::HashMap;
use mutable_batch::{MutableBatch, WritePayload};
use table_batch::{
ValueCollection,
builder::{DictionaryBuffer, StringBuffer, slice_values},
};
use thiserror::Error;
use self::template::Template;
pub use self::traits::{Batch, PartitioningColumn, TimeColumnError};
/// An error generating a partition key for a row.
#[derive(Debug, Error, PartialEq, Eq, Clone)]
pub enum PartitionKeyError {
/// The partition template defines a [`Template::TimeFormat`] part, but the
/// provided strftime formatter is invalid.
#[error("invalid strftime format in partition template")]
InvalidStrftime,
/// The partition template defines a [`Template::TagValue`] part, but the
/// column type is not "tag".
#[error("tag value partitioner does not accept input columns of type {0}")]
TagValueNotTag(String),
/// A "catch all" error for when a formatter returns [`std::fmt::Error`],
/// which contains no context.
#[error("partition key generation error")]
FmtError(#[from] std::fmt::Error),
}
/// Returns an iterator identifying consecutive ranges for a given partition key
pub fn partition_batch<'a, T>(
batch: &'a T,
template: &'a TablePartitionTemplateOverride,
) -> impl Iterator<Item = (Result<String, PartitionKeyError>, Range<usize>)> + 'aView on GitHub (pinned to 06200ef96b)