{"record":{"id":"7fddba9ed645880f","repo":"influxdata/influxdb","slug":"should-render-string","errorCode":null,"errorMessage":"should render string","messagePattern":"should render string","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"core/partition/src/template/strftime.rs","lineNumber":291,"sourceCode":"\n    use super::*;\n\n    #[test]\n    fn test_default_formatter() {\n        let template = TablePartitionTemplateOverride::default();\n        let expect = template.parts().collect::<Vec<_>>();\n\n        // If this assert fails (and it probably shouldn't!) then you may want\n        // to consider changing the special case optimisation above.\n        assert_matches!(expect.as_slice(), &[TemplatePart::TimeFormat(YMD_SPEC)]);\n    }\n\n    #[test]\n    fn test_never_empty() {\n        let mut fmt = StrftimeFormatter::new(\"\");\n\n        let mut buf = String::new();\n        fmt.render(42, &mut buf).expect(\"should render string\");\n        assert!(!buf.is_empty());\n        assert_eq!(buf, \"^\");\n    }\n\n    #[test]\n    fn test_incomplete_formatter() {\n        let mut fmt = StrftimeFormatter::new(\"%\");\n\n        let mut buf = String::new();\n        let got = fmt.render(42, &mut buf);\n        assert_matches!(got, Err(PartitionKeyError::InvalidStrftime));\n    }\n\n    #[test]\n    fn test_incomplete_formatter_removes_bad_mapping() {\n        let mut fmt = StrftimeFormatter::new(\"%s\");\n\n        let mut buf = String::new();","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/partition/src/template/strftime.rs#L273-L309","documentation":"In test_never_empty, StrftimeFormatter::render(42, &mut buf).expect(\"should render string\") panics if rendering a timestamp with an empty format string fails. The empty format must still render a non-empty placeholder ('^') so partition keys are never empty; an Err here means render returned std::fmt::Error.","triggerScenarios":"Calling StrftimeFormatter::new(\"\").render(ts, &mut buf) and getting Err — i.e. the ring-buffer/strftime machinery failed to emit the fallback placeholder for the empty format.","commonSituations":"Only hit when changing the StrftimeFormatter implementation, e.g. breaking the empty-format fallback that renders '^'.","solutions":["Fix StrftimeFormatter::render so an empty format still writes the '^' placeholder","Check the formatter's internal buffer/ring-cache path for early Err returns","Run the adjacent tests (test_incomplete_formatter) to confirm formatter edge cases are handled"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if fmt.render(42, &mut buf).is_err() {\n    eprintln!(\"render failed for empty format; fallback placeholder not written\");\n}","preventionTips":["Keep the empty-format fallback ('^') covered by a unit test","Avoid early Err returns in the formatter's buffer path","Run the strftime test module after any formatter change"],"tags":["rust","test-assertion","strftime","formatting"],"backgroundTag":"internal-invariant-violation","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"}