{"record":{"id":"548307f45437e2e6","repo":"crowdsecurity/crowdsec","slug":"while-parsing-dockeracquisition-configuration-s","errorCode":null,"errorMessage":"while parsing DockerAcquisition configuration: %s","messagePattern":"while parsing DockerAcquisition configuration: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/docker/config.go","lineNumber":60,"sourceCode":"\nfunc (dc *Configuration) hasServiceConfig() bool {\n\treturn len(dc.ServiceName) > 0 || len(dc.ServiceID) > 0 ||\n\t\tlen(dc.ServiceIDRegexp) > 0 || len(dc.ServiceNameRegexp) > 0 || dc.UseServiceLabels\n}\n\nfunc (dc *Configuration) hasContainerConfig() bool {\n\treturn len(dc.ContainerName) > 0 || len(dc.ContainerID) > 0 ||\n\t\tlen(dc.ContainerIDRegexp) > 0 || len(dc.ContainerNameRegexp) > 0 || dc.UseContainerLabels\n}\n\nfunc (d *Source) UnmarshalConfig(yamlConfig []byte) error {\n\td.Config = Configuration{\n\t\tFollowStdout: true, // default\n\t\tFollowStdErr: true, // default\n\t}\n\n\tif err := yaml.UnmarshalWithOptions(yamlConfig, &d.Config, yaml.Strict()); err != nil {\n\t\treturn fmt.Errorf(\"while parsing DockerAcquisition configuration: %s\", yaml.FormatError(err, false, false))\n\t}\n\n\tif d.logger != nil {\n\t\td.logger.Tracef(\"DockerAcquisition configuration: %+v\", d.Config)\n\t}\n\n\t// Check if we have any container or service configuration\n\tif !d.Config.hasContainerConfig() && !d.Config.hasServiceConfig() {\n\t\treturn errors.New(\"no containers or services configuration provided\")\n\t}\n\n\tif d.Config.UseContainerLabels && (len(d.Config.ContainerName) > 0 || len(d.Config.ContainerID) > 0 || len(d.Config.ContainerIDRegexp) > 0 || len(d.Config.ContainerNameRegexp) > 0) {\n\t\treturn errors.New(\"use_container_labels and container_name, container_id, container_id_regexp, container_name_regexp are mutually exclusive\")\n\t}\n\n\tif d.Config.UseServiceLabels && (len(d.Config.ServiceName) > 0 || len(d.Config.ServiceID) > 0 || len(d.Config.ServiceIDRegexp) > 0 || len(d.Config.ServiceNameRegexp) > 0) {\n\t\treturn errors.New(\"use_service_labels and service_name, service_id, service_id_regexp, service_name_regexp are mutually exclusive\")\n\t}","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/docker/config.go#L42-L78","documentation":"UnmarshalConfig decodes the docker datasource YAML with yaml.Strict(), which rejects any unknown or mistyped field. On failure the error is wrapped as `while parsing DockerAcquisition configuration: <formatted error>`. The datasource cannot be configured and acquisition of that source fails.","triggerScenarios":"An acquisition YAML for the docker datasource contains a key not present in the Configuration struct (e.g. `container_name:` instead of `container_name_regexp:`), a wrong-typed value, or a duplicate key — all rejected by strict unmarshalling.","commonSituations":"Copying config from another datasource type; old config keys removed in newer crowdsec versions; indentation mistakes creating unexpected keys; boolean fields given string values.","solutions":["Read the formatted error: yaml.FormatError names the exact offending field and line","Remove or rename the unknown/misspelled key to one supported by the docker datasource (follow_stdout, follow_stderr, container_name_regexp, container_id, docker_host, mode, etc.)","Fix value types to match the struct (booleans as true/false, string lists for regexps)"],"exampleFix":"// before\nsource: docker\n  container_name: myapp\n// after\nsource: docker\n  container_name_regexp:\n    - myapp","handlingStrategy":"validation","validationCode":"var raw map[string]interface{}\nif err := yaml.Unmarshal(yamlBlock, &raw); err != nil { return err }\nknown := map[string]bool{\"mode\":true,\"docker_host\":true,\"follow_stdout\":true,\"follow_stderr\":true,\"container_name_regexp\":true,\"container_id\":true,\"check_all\":true,\"force_inotify\":true}\nfor k := range raw { if !known[k] { return fmt.Errorf(\"unknown docker key %q\", k) } }","typeGuard":null,"tryCatchPattern":"if err := ds.UnmarshalConfig(yamlConfig); err != nil {\n    // yaml.FormatError output names the offending line/field — surface it to the operator\n    return fmt.Errorf(\"acquisition config rejected: %v\", err)\n}","preventionTips":["Only use documented docker datasource keys","Validate acquisition YAML with cscli before restarting crowdsec","Watch for key renames across crowdsec versions when upgrading","Quote strings with special YAML characters"],"tags":["config","yaml","docker","strict-parsing"],"backgroundTag":"schema-validation-failed","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"}