{"record":{"id":"4e1b0a012a6b9c8c","repo":"crowdsecurity/crowdsec","slug":"target-is-not-a-map-string-string","errorCode":null,"errorMessage":"target is not a map[string]string","messagePattern":"target is not a map\\[string\\]string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/exprhelpers/helpers.go","lineNumber":997,"sourceCode":"\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 {\n\t\t\tcase name == \"key\":\n\t\t\t\tkey = match[i]\n\t\t\tcase name == \"quoted_value\" && match[i] != \"\":\n\t\t\t\tvalue = match[i]\n\t\t\tcase name == \"value\" && match[i] != \"\":\n\t\t\t\tvalue = match[i]\n\t\t\t}\n\t\t}\n","sourceCodeStart":979,"sourceCodeEnd":1015,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/exprhelpers/helpers.go#L979-L1015","documentation":"Type guard in ParseKV: the target map already contains an entry under the given prefix, but that existing value is not a map[string]string — a previous stage stored an incompatible type under the same prefix key.","triggerScenarios":"Thrown at pkg/exprhelpers/helpers.go:997 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a fresh/unique prefix for each ParseKV call so target entries don't collide","Ensure earlier stages don't write non-KV data under the same prefix key"],"exampleFix":null,"handlingStrategy":"type-guard","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"}