{"record":{"id":"e29aa71cbcdf4c66","repo":"influxdata/influxdb","slug":"invalid-strftime-format-in-partition-template","errorCode":null,"errorMessage":"invalid strftime format in partition template","messagePattern":"invalid strftime format in partition template","errorType":"error_code","errorClass":"PartitionKeyError","httpStatus":null,"severity":"error","filePath":"core/partition/src/lib.rs","lineNumber":38,"sourceCode":"    },\n};\nuse hashbrown::HashMap;\nuse mutable_batch::{MutableBatch, WritePayload};\nuse table_batch::{\n    ValueCollection,\n    builder::{DictionaryBuffer, StringBuffer, slice_values},\n};\nuse thiserror::Error;\n\nuse self::template::Template;\npub use self::traits::{Batch, PartitioningColumn, TimeColumnError};\n\n/// An error generating a partition key for a row.\n#[derive(Debug, Error, PartialEq, Eq, Clone)]\npub enum PartitionKeyError {\n    /// The partition template defines a [`Template::TimeFormat`] part, but the\n    /// provided strftime formatter is invalid.\n    #[error(\"invalid strftime format in partition template\")]\n    InvalidStrftime,\n\n    /// The partition template defines a [`Template::TagValue`] part, but the\n    /// column type is not \"tag\".\n    #[error(\"tag value partitioner does not accept input columns of type {0}\")]\n    TagValueNotTag(String),\n\n    /// A \"catch all\" error for when a formatter returns [`std::fmt::Error`],\n    /// which contains no context.\n    #[error(\"partition key generation error\")]\n    FmtError(#[from] std::fmt::Error),\n}\n\n/// Returns an iterator identifying consecutive ranges for a given partition key\npub fn partition_batch<'a, T>(\n    batch: &'a T,\n    template: &'a TablePartitionTemplateOverride,\n) -> impl Iterator<Item = (Result<String, PartitionKeyError>, Range<usize>)> + 'a","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/partition/src/lib.rs#L20-L56","documentation":"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.","triggerScenarios":"Building partition keys for rows whose template includes Template::TimeFormat with an invalid strftime spec (e.g. stray '%', unsupported specifier).","commonSituations":"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.","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"],"exampleFix":"// before\nlet tpl = Template::parse(\"%Y-%m-%d %Q\")?; // %Q invalid\n// after\nlet tpl = Template::parse(\"%Y-%m-%dT%H%M\")?;","handlingStrategy":"validation","validationCode":"// validate at config load time\nlet fmt: strftime::Fmt = format.parse().map_err(|_| \"invalid strftime format in partition template\")?;","typeGuard":null,"tryCatchPattern":"match make_partition_key(row, &template) {\n    Err(PartitionKeyError::InvalidStrftime) => reject_template(template),\n    Err(e) => return Err(e.into()),\n    Ok(key) => key,\n}","preventionTips":["Validate partition templates when they are configured, not per-row","Test templates against a sample timestamp at startup"],"tags":["partition","strftime","configuration"],"backgroundTag":"invalid-date-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"}