{"record":{"id":"7d44889255af72b6","repo":"crowdsecurity/crowdsec","slug":"invalid-input-format","errorCode":null,"errorMessage":"invalid input format","messagePattern":"invalid input format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/exprhelpers/helpers.go","lineNumber":988,"sourceCode":"\tencoded := params[0].(string)\n\n\tdecoded, err := base64.StdEncoding.DecodeString(encoded)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(decoded), nil\n}\n\nfunc ParseKV(params ...any) (any, error) {\n\tblob := params[0].(string)\n\ttarget := params[1].(map[string]any)\n\tprefix := params[2].(string)\n\n\tmatches := keyValuePattern.FindAllStringSubmatch(blob, -1)\n\tif matches == nil {\n\t\tlog.Errorf(\"could not find any key/value pair in line\")\n\t\treturn nil, errors.New(\"invalid input format\")\n\t}\n\n\tif _, ok := target[prefix]; !ok {\n\t\ttarget[prefix] = make(map[string]string)\n\t} else {\n\t\t_, ok := target[prefix].(map[string]string)\n\t\tif !ok {\n\t\t\tlog.Errorf(\"ParseKV: target is not a map[string]string\")\n\t\t\treturn nil, errors.New(\"target is not a map[string]string\")\n\t\t}\n\t}\n\n\tfor _, match := range matches {\n\t\tkey := \"\"\n\t\tvalue := \"\"\n\n\t\tfor i, name := range keyValuePattern.SubexpNames() {\n\t\t\tswitch {","sourceCodeStart":970,"sourceCodeEnd":1006,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/exprhelpers/helpers.go#L970-L1006","documentation":"ParseKV (an expr helper) found no key/value pairs matching keyValuePattern in the input line passed to ParseKV(); the blob contained no recognized 'key: value' or similar pairs, so the target map is left unpopulated and the expression fails.","triggerScenarios":"Thrown at pkg/exprhelpers/helpers.go:988 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the log format actually contains key=value pairs","Apply ParseKV only after a parser stage that produces KV-formatted output","Adjust the upstream parser to normalize lines into key=value form"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}