{"record":{"id":"989738aec2090919","repo":"crowdsecurity/crowdsec","slug":"cannot-parse-s-989738","errorCode":null,"errorMessage":"cannot parse: %s","messagePattern":"cannot parse: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/kafka/config.go","lineNumber":52,"sourceCode":"\tClientCert         string `yaml:\"client_cert\"`\n\tClientKey          string `yaml:\"client_key\"`\n\tCaCert             string `yaml:\"ca_cert\"`\n}\n\ntype KafkaBatchConfiguration struct {\n\tBatchMinBytes  int           `yaml:\"min_bytes\"`\n\tBatchMaxBytes  int           `yaml:\"max_bytes\"`\n\tBatchMaxWait   time.Duration `yaml:\"max_wait\"`\n\tBatchQueueSize int           `yaml:\"queue_size\"`\n\tCommitInterval time.Duration `yaml:\"commit_interval\"`\n}\n\nfunc (s *Source) UnmarshalConfig(yamlConfig []byte) error {\n\ts.Config = Configuration{}\n\n\terr := yaml.UnmarshalWithOptions(yamlConfig, &s.Config, yaml.Strict())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot parse: %s\", yaml.FormatError(err, false, false))\n\t}\n\n\tif len(s.Config.Brokers) == 0 {\n\t\treturn fmt.Errorf(\"cannot create a %s reader with an empty list of broker addresses\", s.GetName())\n\t}\n\n\tif s.Config.Topic == \"\" {\n\t\treturn fmt.Errorf(\"cannot create a %s reader with an empty topic\", s.GetName())\n\t}\n\n\tif s.Config.Mode == \"\" {\n\t\ts.Config.Mode = configuration.TAIL_MODE\n\t}\n\n\ts.logger.Debugf(\"successfully parsed kafka configuration : %+v\", s.Config)\n\n\treturn err\n}","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/kafka/config.go#L34-L70","documentation":"The kafka source unmarshals its YAML configuration in strict mode; invalid YAML or unknown/misspelled keys (e.g. 'broker' instead of 'brokers', 'topicn') produce this error wrapped as 'cannot parse: <detail>'. The detail names the exact problem field or syntax issue.","triggerScenarios":"Calling Source.UnmarshalConfig with a kafka acquis YAML block containing an unknown key, wrong field type (e.g. brokers as a string instead of a list), or YAML syntax errors.","commonSituations":"Copying kafka config from another product with different key names; specifying brokers as a single comma-separated string instead of a YAML list; indentation or quoting mistakes.","solutions":["Read the detail after 'cannot parse:' to find the unknown field or syntax problem.","Use the documented kafka keys: brokers (list of host:port), topic, and optional timeout, balanced consumer group fields, etc.","Express brokers as a YAML list, not a single string.","Validate the YAML with a linter before restarting crowdsec."],"exampleFix":"// before\nsource: kafka\nbrokers: kafka1:9092,kafka2:9092\n// after\nsource: kafka\nbrokers:\n  - kafka1:9092\n  - kafka2:9092\ntopic: crowdsec","handlingStrategy":"validation","validationCode":"var probe map[string]interface{}\nif err := yaml.Unmarshal(yamlCfg, &probe); err != nil {\n    return fmt.Errorf(\"invalid kafka YAML: %w\", err)\n}\nallowed := map[string]bool{\"brokers\": true, \"topic\": true, \"mode\": true, \"timeout\": true}\nfor k := range probe {\n    if !allowed[k] { return fmt.Errorf(\"unknown kafka key: %s\", k) }\n}","typeGuard":null,"tryCatchPattern":"if err := source.UnmarshalConfig(cfg); err != nil {\n    if strings.HasPrefix(err.Error(), \"cannot parse:\") {\n        // log detail, fall back to last-known-good config\n    }\n}","preventionTips":["Specify brokers as a YAML list of host:port strings","Validate YAML indentation with a linter before deploying","Only use kafka source keys from the docs for your version"],"tags":["go","yaml","kafka","configuration"],"backgroundTag":"yaml-parse-error","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}