{"record":{"id":"cbc25364f6afccac","repo":"influxdata/influxdb","slug":"partition-template-must-include-a-time-format-part","errorCode":null,"errorMessage":"partition template must include a time format part","messagePattern":"partition template must include a time format part","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"core/data_types/src/partition_template.rs","lineNumber":255,"sourceCode":"        \"number of buckets in partition template must be in range \\\n        [{ALLOWED_BUCKET_QUANTITIES:?}), number specified: {0}\"\n    )]\n    InvalidNumberOfBuckets(u32),\n\n    /// The partition template defines a [`TagValue`] or [`Bucket`] part\n    /// which repeats a tag name used in another [`TagValue`] or [`Bucket`] part.\n    /// This is not allowed\n    ///\n    /// [`TagValue`]: [`proto::template_part::Part::TagValue`]\n    /// [`Bucket`]: [`proto::template_part::Part::Bucket`]\n    #[error(\"tag name value cannot be repeated in partition template: {0}\")]\n    RepeatedTagValue(String),\n\n    /// An attempt to make a new partition template without a [`TimeFormat`]\n    /// part has been made. This is not allowed.\n    ///\n    /// [`TimeFormat`]: [`proto::template_part::Part::TimeFormat`]\n    #[error(\"partition template must include a time format part\")]\n    TimeFormatPartRequired,\n\n    /// The partition template defines a [`TimeFormat`] part, but the\n    /// provided strftime formatter contains unsupported specifiers.\n    ///\n    /// [`TimeFormat`]: [`proto::template_part::Part::TimeFormat`]\n    #[error(\"unsupported specifier found in time format \\\"{0}\\\" - supported specifiers: {1}\")]\n    UnsupportedStrfTimeSpecifier(String, String),\n\n    /// The partition template defines a [`TimeFormat`] part, but the\n    /// provided strftime format that is missing required specifiers.\n    ///\n    /// For example: using %m without %Y.\n    ///\n    /// [`TimeFormat`]: [`proto::template_part::Part::TimeFormat`]\n    #[error(\"missing required specifier(s) in time format of partition template: {0}\")]\n    MissingRequiredStrfTimeSpecifier(String),\n}","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/data_types/src/partition_template.rs#L237-L273","documentation":"Thrown by `TimeFormatPartRequired` when a partition template is built without any TimeFormat part. Every custom partition template must include a time-based part so partitions are anchored to time; the library rejects templates composed only of TagValue/Bucket parts.","triggerScenarios":"Calling `PartitionTemplate::new` (or the create-database template API) with parts like `[Part::TagValue(\"region\")]` and no `Part::TimeFormat`; a migration or tooling path that drops the default `%Y` time format part.","commonSituations":"Writing a minimal custom template to partition purely by tag and forgetting the time part; older templates written before the time-format requirement was enforced; generated configs omitting the default part.","solutions":["Add a `Part::TimeFormat` part (e.g. `%Y`) to the template's parts list.","If you want daily partitions use `Part::TimeFormat(\"%Y-%m-%d\")`; at minimum include `%Y`.","If the template comes from a stored config, backfill the missing TimeFormat part before re-applying it."],"exampleFix":"// before\nparts: vec![Part::TagValue(\"region\".into())]\n// after\nparts: vec![Part::TimeFormat(\"%Y\".into()), Part::TagValue(\"region\".into())]","handlingStrategy":"validation","validationCode":"fn has_time_format(parts: &[Part]) -> bool {\n    matches!(parts.iter().find(|p| matches!(p, Part::TimeFormat(_))), Some(_))\n}\nassert!(has_time_format(&parts), \"template needs a TimeFormat part\");","typeGuard":null,"tryCatchPattern":"match PartitionTemplate::new(parts) {\n    Err(e) if e.to_string().contains(\"time format part\") => {\n        // auto-heal: prepend a default year part\n        let mut fixed = vec![Part::TimeFormat(\"%Y\".into())];\n        fixed.extend(parts);\n        PartitionTemplate::new(fixed).map_err(Into::into)\n    }\n    other => other.map_err(Into::into),\n}","preventionTips":["Always include at least %Y in any custom template.","Start templates from the default (time-first) template and append tag parts.","Validate stored/legacy templates for a TimeFormat part before re-applying them."],"tags":["rust","partitioning","missing-required-field","validation"],"backgroundTag":"missing-required-argument","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"}