{"record":{"id":"abba2d249b24a55d","repo":"amir20/dozzle","slug":"invalid-format-unexpected-space-in-key","errorCode":null,"errorMessage":"invalid format: unexpected space in key","messagePattern":"invalid format: unexpected space in key","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/container/logfmt.go","lineNumber":30,"sourceCode":"func ParseLogFmt(log string) (*orderedmap.OrderedMap[string, string], error) {\n\tresult := orderedmap.New[string, string]()\n\tvar key, value string\n\tinQuotes, escaping, isKey := false, false, true\n\tstart := 0\n\n\tfor i := 0; i < len(log); i++ {\n\t\tchar := log[i]\n\t\tif isKey {\n\t\t\tif char == '=' {\n\t\t\t\tif start >= i {\n\t\t\t\t\treturn nil, errors.New(\"invalid format: key is empty\")\n\t\t\t\t}\n\t\t\t\tkey = log[start:i]\n\t\t\t\tisKey = false\n\t\t\t\tstart = i + 1\n\t\t\t} else if char == ' ' {\n\t\t\t\tif i > start {\n\t\t\t\t\treturn nil, errors.New(\"invalid format: unexpected space in key\")\n\t\t\t\t}\n\t\t\t}\n\n\t\t} else {\n\t\t\tif inQuotes {\n\t\t\t\tif escaping {\n\t\t\t\t\tescaping = false\n\t\t\t\t} else if char == '\\\\' {\n\t\t\t\t\tescaping = true\n\t\t\t\t} else if char == '\"' {\n\t\t\t\t\tvalue = unescapeQuoted(log[start-1 : i+1])\n\t\t\t\t\tresult.Set(key, value)\n\t\t\t\t\tinQuotes = false\n\t\t\t\t\tisKey = true\n\t\t\t\t\tstart = i + 2\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif char == '\"' {","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/container/logfmt.go#L12-L48","documentation":"ParseLogFmt rejects a logfmt line where a key being scanned contains a space followed by more characters before '=' (e.g. 'foo bar=1'). The parser only allows spaces between pairs, so a space inside a key position means the line is not valid logfmt and parsing aborts for the whole line.","triggerScenarios":"Thrown at internal/container/logfmt.go:30 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the emitting application so keys contain no spaces (logfmt keys must be bare tokens).","Quote the key's value properly instead, e.g. change 'foo bar=1' to 'foo=bar key=value'.","Pre-sanitize or drop non-conforming log lines before calling ParseLogFmt if upstream logs are untrusted."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}