{"record":{"id":"c139e2951c4b9de6","repo":"gitbutlerapp/gitbutler","slug":"invalid-trailer-format-expected-key-value","errorCode":null,"errorMessage":"Invalid trailer format, expected `key: value`","messagePattern":"Invalid trailer format, expected `key: value`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/but-core/src/snapshot/mod.rs","lineNumber":57,"sourceCode":"        pub key: String,\n        /// Trailer value.\n        pub value: String,\n    }\n\n    impl Display for CommitTrailer {\n        fn fmt(&self, f: &mut Formatter) -> fmt::Result {\n            let escaped_value = self.value.replace('\\n', \"\\\\n\");\n            write!(f, \"{}: {}\", self.key, escaped_value)\n        }\n    }\n\n    impl FromStr for CommitTrailer {\n        type Err = anyhow::Error;\n\n        fn from_str(s: &str) -> anyhow::Result<Self, Self::Err> {\n            let mut parts = s.splitn(2, ':');\n            let (Some(key), Some(value)) = (parts.next(), parts.next()) else {\n                return Err(anyhow!(\"Invalid trailer format, expected `key: value`\"));\n            };\n            let unescaped_value = value.trim().replace(\"\\\\n\", \"\\n\");\n            Ok(Self {\n                key: key.trim().to_string(),\n                value: unescaped_value,\n            })\n        }\n    }\n\n    /// Metadata attached to [`Commit`]s holding snapshots.\n    pub struct CommitMetadata {\n        /// The name of the operation that created the commit.\n        /// This is an internal string.\n        pub operation: String,\n        /// The title of the commit for user consumption, typically created using information from `trailers`.\n        pub title: String,\n        /// Properties to be stored with the commit.\n        pub trailers: Vec<CommitTrailer>,","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-core/src/snapshot/mod.rs#L39-L75","documentation":"CommitTrailer::from_str parses a trailer string that must have the shape `key: value`. If the string contains no colon, splitn(2, ':') yields only one part and this anyhow error is raised. The parser is intentionally strict: trailers without a colon cannot be split into a key and value.","triggerScenarios":"Passing a trailer string without a colon to CommitTrailer::from_str / str::parse::<CommitTrailer>() — e.g. \"Signed-off-by John\" instead of \"Signed-off-by: John <x@y.z>\" or an empty/whitespace-only token from splitting a commit message.","commonSituations":"Hand-written trailer lists; splitting trailers on newline where a blank line sneaks in; reading trailers from external tooling that omits the colon.","solutions":["Ensure each trailer contains a colon separating key and value before parsing","Filter out empty/malformed lines before calling from_str","Fix the commit message trailer itself with `git commit --amend` or `git interpret-trailers`"],"exampleFix":"// before\nlet t: CommitTrailer = \"Reviewed-by Alice\".parse()?;\n// after\nlet t: CommitTrailer = \"Reviewed-by: Alice\".parse()?; // key: value","handlingStrategy":"validation","validationCode":"fn looks_like_trailer(s: &str) -> bool { s.split_once(':').is_some() }\nlet trailers: Result<Vec<_>, _> = lines.filter(|l| looks_like_trailer(l))\n    .map(CommitTrailer::from_str).collect();","typeGuard":"fn parse_trailer(s: &str) -> Option<CommitTrailer> {\n    let (k, v) = s.split_once(':')?;\n    Some(CommitTrailer::new(k.trim(), v.trim()))\n}","tryCatchPattern":"match s.parse::<CommitTrailer>() {\n    Ok(t) => t,\n    Err(e) if e.to_string().contains(\"key: value\") => skip_or_log(s),\n    Err(e) => return Err(e),\n}","preventionTips":["Format trailers strictly as `key: value` (colon required)","Skip blank lines when iterating commit-message lines","Use `git interpret-trailers` output as the source of trailer strings"],"tags":["parsing","format","git-trailers"],"backgroundTag":"invalid-argument-format","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}