{"record":{"id":"6d56f01079cce53c","repo":"crowdsecurity/crowdsec","slug":"no-labels-key","errorCode":null,"errorMessage":"no labels key","messagePattern":"no labels key","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/docker/source.go","lineNumber":102,"sourceCode":"\tif _, ok := parsedLabels[\"enable\"]; !ok {\n\t\td.logger.Errorf(\"%s has 'crowdsec' labels set but no 'crowdsec.enable' key found\", entityType)\n\t\treturn nil, errors.New(\"no crowdsec.enable key\")\n\t}\n\n\tenable, ok := parsedLabels[\"enable\"].(string)\n\tif !ok {\n\t\td.logger.Errorf(\"%s has 'crowdsec.enable' label set but it's not a string\", entityType)\n\t\treturn nil, errors.New(\"crowdsec.enable not a string\")\n\t}\n\n\tif strings.ToLower(enable) != \"true\" {\n\t\td.logger.Debugf(\"%s has 'crowdsec.enable' label not set to true ignoring %s: %s\", entityType, entityType, entityID)\n\t\treturn nil, errors.New(\"crowdsec.enable not true\")\n\t}\n\n\tif _, ok = parsedLabels[\"labels\"]; !ok {\n\t\td.logger.Errorf(\"%s has 'crowdsec.enable' label set to true but no 'labels' keys found\", entityType)\n\t\treturn nil, errors.New(\"no labels key\")\n\t}\n\n\tlabelsTypeCast, ok := parsedLabels[\"labels\"].(map[string]any)\n\tif !ok {\n\t\td.logger.Errorf(\"%s has 'crowdsec.enable' label set to true but 'labels' is not a map\", entityType)\n\t\treturn nil, errors.New(\"labels not a map\")\n\t}\n\n\td.logger.Debugf(\"%s labels %+v\", entityType, labelsTypeCast)\n\n\tlabels := make(map[string]string)\n\n\tfor k, v := range labelsTypeCast {\n\t\tif v, ok := v.(string); ok {\n\t\t\tlog.Debugf(\"label %s is a string with value %s\", k, v)\n\t\t\tlabels[k] = v\n\t\t\tcontinue\n\t\t}","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/docker/source.go#L84-L120","documentation":"The entity is enabled via crowdsec.enable=true, but processCrowdsecLabels requires a 'crowdsec.labels' map that tells it which labels to apply to parsed events (e.g. type, program). When the 'labels' key is absent, the entity cannot be configured and is rejected.","triggerScenarios":"EvalContainer/EvalService -> processCrowdsecLabels with parsedLabels containing enable=true but no 'labels' entry — e.g. only 'crowdsec.enable=true' set on the container.","commonSituations":"User enables acquisition but never sets crowdsec.labels (incomplete setup); labels block accidentally deleted during edit; wrong nesting so crowdsec.labels ends up as a sibling/flat label instead of a map.","solutions":["Add a crowdsec.labels map, e.g. crowdsec.labels.type=syslog (or labels: type: syslog under crowdsec in compose)","Ensure 'labels' is nested under the crowdsec key, not at the top level","Mirror a working example from the crowdsec docker acquisition docs and adapt it","Re-inspect the container to confirm both crowdsec.enable and crowdsec.labels are present"],"exampleFix":"# before\nlabels:\n  - crowdsec.enable=true\n# after\nlabels:\n  - crowdsec.enable=true\n  - crowdsec.labels.type=syslog","handlingStrategy":"validation","validationCode":"if strings.EqualFold(labels[\"crowdsec.enable\"], \"true\") {\n\tif _, ok := labels[\"crowdsec.labels.type\"]; !ok {\n\t\treturn fmt.Errorf(\"container %s: crowdsec.labels map missing\", ctr.ID)\n\t}\n}","typeGuard":"func hasLabelsMap(parsed map[string]any) bool {\n\t_, ok := parsed[\"labels\"]\n\treturn ok\n}","tryCatchPattern":"if _, err := source.EvalContainer(ctx, ctr); err != nil {\n\tif err.Error() == \"no labels key\" {\n\t\tlog.Errorf(\"container %s: set crowdsec.labels alongside crowdsec.enable=true\", ctr.ID)\n\t}\n}","preventionTips":["Copy a complete label block (enable + labels) from the docs, never just enable","Verify nesting: crowdsec.labels is a map, not a sibling key","Compose lint rule: crowdsec.enable=true requires at least one crowdsec.labels.* entry"],"tags":["docker","labels","configuration"],"backgroundTag":"missing-config-key","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"}