{"record":{"id":"0b1aa080787ff979","repo":"crowdsecurity/crowdsec","slug":"no-crowdsec-enable-key","errorCode":null,"errorMessage":"no crowdsec.enable key","messagePattern":"no crowdsec\\.enable key","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/docker/source.go","lineNumber":86,"sourceCode":"\nfunc (d *Source) getContainerLabels(ctx context.Context, containerID string) map[string]any {\n\tcontainerDetails, err := d.Client.ContainerInspect(ctx, containerID, client.ContainerInspectOptions{})\n\tif err != nil {\n\t\treturn map[string]any{}\n\t}\n\n\treturn parseLabels(containerDetails.Container.Config.Labels)\n}\n\nfunc (d *Source) processCrowdsecLabels(parsedLabels map[string]any, entityID string, entityType string) (map[string]string, error) {\n\tif len(parsedLabels) == 0 {\n\t\td.logger.Tracef(\"%s has no 'crowdsec' labels set, ignoring %s: %s\", entityType, entityType, entityID)\n\t\treturn nil, errors.New(\"no crowdsec labels\")\n\t}\n\n\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","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/docker/source.go#L68-L104","documentation":"The docker acquisiton source found at least one 'crowdsec.*' label on the container/service, but the required 'crowdsec.enable' label is missing. processCrowdsecLabels only accepts entities that explicitly opt in with enable=true, so without that key the entity is rejected and never acquired. It is a user configuration error on the Docker entity, not an internal failure.","triggerScenarios":"EvalContainer or EvalService calls processCrowdsecLabels on an entity whose labels contain a crowdsec.* key (e.g. crowdsec.labels: ... ) but no 'enable' key, e.g. label 'crowdsec.labels' set without 'crowdsec.enable'.","commonSituations":"User adds crowdsec.labels to a docker-compose service to route logs but forgets crowdsec.enable=true; copy-pasted label blocks with the enable line dropped; templating that conditionally emits enable; typo like crowdsec.enabled or enable under the wrong prefix.","solutions":["Add the label crowdsec.enable=true to the container/service","Fix the label key spelling: it must be exactly 'crowdsec.enable' (e.g. correct crowdsec.enabled or crowdsec-enable)","If the container should not be acquired, remove all crowdsec.* labels instead of leaving a partial set","Verify with 'docker inspect <container>' that the effective labels contain crowdsec.enable=true"],"exampleFix":"// before (docker-compose.yml)\nlabels:\n  - crowdsec.labels.type=syslog\n// after\nlabels:\n  - crowdsec.enable=true\n  - crowdsec.labels.type=syslog","handlingStrategy":"validation","validationCode":"labels := container.Labels\nif _, ok := labels[\"crowdsec.enable\"]; !ok {\n\treturn fmt.Errorf(\"container %s: crowdsec.enable label missing (got %v)\", container.ID, labels)\n}","typeGuard":"func hasCrowdsecEnable(labels map[string]string) bool {\n\t_, ok := labels[\"crowdsec.enable\"]\n\treturn ok\n}","tryCatchPattern":"if _, err := source.EvalContainer(ctx, ctr); err != nil {\n\tif err.Error() == \"no crowdsec.enable key\" {\n\t\tlog.Warnf(\"container %s: add crowdsec.enable=true\", ctr.ID)\n\t}\n\t// ignore other opt-out errors silently\n}","preventionTips":["Always pair crowdsec.labels with crowdsec.enable=true in templates","Lint compose files for required crowdsec.enable when any crowdsec.* label exists","docker inspect the container before debugging acquisition"],"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-14T05:17:10.506Z"}