{"record":{"id":"902aff29b3d5e49c","repo":"influxdata/influxdb","slug":"invalid-strftime-format-in-partition-template-0","errorCode":null,"errorMessage":"invalid strftime format in partition template: {0}","messagePattern":"invalid strftime format in partition template: (.+?)","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"core/data_types/src/partition_template.rs","lineNumber":221,"sourceCode":"    #[error(\"Custom partition template must have at least one part\")]\n    NoParts,\n\n    /// The partition template exceeded the maximum allowed number of parts.\n    #[error(\n        \"Custom partition template specified {specified} parts. \\\n        Partition templates may have a maximum of {MAXIMUM_NUMBER_OF_TEMPLATE_PARTS} parts.\"\n    )]\n    TooManyParts {\n        /// The number of template parts that were present in the user-provided custom partition\n        /// template.\n        specified: usize,\n    },\n\n    /// The partition template defines a [`TimeFormat`] part, but the\n    /// provided strftime formatter is invalid.\n    ///\n    /// [`TimeFormat`]: [`proto::template_part::Part::TimeFormat`]\n    #[error(\"invalid strftime format in partition template: {0}\")]\n    InvalidStrftime(String),\n\n    /// The partition template defines a [`TagValue`] part or [`Bucket`] part,\n    /// but the provided tag name value is invalid.\n    ///\n    /// [`TagValue`]: [`proto::template_part::Part::TagValue`]\n    /// [`Bucket`]: [`proto::template_part::Part::Bucket`]\n    #[error(\"invalid tag name value in partition template: {0}\")]\n    InvalidTagValue(String),\n\n    /// The partition template defines a [`Bucket`] part, but the provided\n    /// number of buckets is invalid.\n    ///\n    /// [`Bucket`]: [`proto::template_part::Part::Bucket`]\n    #[error(\n        \"number of buckets in partition template must be in range \\\n        [{ALLOWED_BUCKET_QUANTITIES:?}), number specified: {0}\"\n    )]","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/data_types/src/partition_template.rs#L203-L239","documentation":"This error is returned when a partition template defines a `TimeFormat` part whose strftime format string cannot be compiled by the underlying strftime implementation. The library validates format strings at template-construction time so invalid formatters are rejected before data is written. The offending string is carried in the `String` payload.","triggerScenarios":"Calling `PartitionTemplateBuilder::add_strftime_format(...)` (or validating a proto template with a `TimeFormat` part) with a malformed strftime spec, e.g. an unclosed `%`, unsupported conversion specifier, or non-UTF8-incompatible pattern.","commonSituations":"Typos in format strings like `%Y-%m` missing a specifier or `%Q` (unsupported); copying formats from libraries with nonstandard directives; localization differences in accepted directives; empty or truncated format strings from config files.","solutions":["Fix the strftime string to use only supported directives (e.g., `%Y`, `%m`, `%d`, `%H`); test it with the same strftime implementation the library uses","Verify each `%` is followed by a valid conversion specifier and there are no stray `%` characters","Check the library's supported time-format directives (crate docs/chrono version) — some extensions differ across versions","Validate user-supplied formats at config-ingest time with a small probe before creating the template"],"exampleFix":"// before\nbuilder.add_strftime_format(\"%Y-%m-%d %Q\"); // unsupported directive\n// after\nbuilder.add_strftime_format(\"%Y-%m-%d %H\");","handlingStrategy":"validation","validationCode":"fn probe_strftime(fmt: &str) -> bool {\n    // compile the format once via the same strftime engine the library uses\n    chrono::format::StrftimeItems::new(fmt).parse(fmt).is_ok()\n        && !fmt.is_empty()\n}\nif !probe_strftime(&user_fmt) { return Err(format!(\"invalid strftime format: {}\", user_fmt)); }","typeGuard":"fn valid_time_format(fmt: &str) -> Option<&str> {\n    (!fmt.is_empty() && fmt.bytes().filter(|&b| b == b'%').count() > 0).then_some(fmt)\n}","tryCatchPattern":"let template = builder.build().map_err(|e| match e {\n    ValidationError::InvalidStrftime(fmt) => anyhow!(\"fix strftime format {:?}: unsupported or malformed directive\", fmt),\n    other => anyhow!(other),\n})?;","preventionTips":["Test format strings with the same strftime implementation/chrono version the library links","Reject empty format strings and stray `%` characters at config ingest","Stick to standard directives (%Y %m %d %H %M) and avoid platform-specific extensions","Add a unit test that builds the template for every user-configurable time format"],"tags":["rust","partition-template","strftime","time-format","validation"],"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"}