{"record":{"id":"b575762b12225c00","repo":"docker/cli","slug":"test-and-disable-can-t-be-set-at-the-same-time","errorCode":null,"errorMessage":"test and disable can't be set at the same time","messagePattern":"test and disable can't be set at the same time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/service.go","lineNumber":443,"sourceCode":"\t\tif hostName, ipAddr, ok := strings.Cut(hostIP, \":\"); ok {\n\t\t\t// Convert to SwarmKit notation: IP-address hostname(s)\n\t\t\thosts = append(hosts, ipAddr+\" \"+hostName)\n\t\t}\n\t}\n\treturn hosts\n}\n\nfunc convertHealthcheck(healthcheck *composetypes.HealthCheckConfig) (*container.HealthConfig, error) {\n\tif healthcheck == nil {\n\t\treturn nil, nil\n\t}\n\tvar (\n\t\ttimeout, interval, startPeriod, startInterval time.Duration\n\t\tretries                                       int\n\t)\n\tif healthcheck.Disable {\n\t\tif len(healthcheck.Test) != 0 {\n\t\t\treturn nil, errors.New(\"test and disable can't be set at the same time\")\n\t\t}\n\t\treturn &container.HealthConfig{\n\t\t\tTest: []string{\"NONE\"},\n\t\t}, nil\n\t}\n\tif healthcheck.Timeout != nil {\n\t\ttimeout = time.Duration(*healthcheck.Timeout)\n\t}\n\tif healthcheck.Interval != nil {\n\t\tinterval = time.Duration(*healthcheck.Interval)\n\t}\n\tif healthcheck.StartPeriod != nil {\n\t\tstartPeriod = time.Duration(*healthcheck.StartPeriod)\n\t}\n\tif healthcheck.StartInterval != nil {\n\t\tstartInterval = time.Duration(*healthcheck.StartInterval)\n\t}\n\tif healthcheck.Retries != nil {","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/convert/service.go#L425-L461","documentation":"Returned by convertHealthcheck (compose/convert/service.go:441-444) when a Compose service's healthcheck sets both 'disable: true' AND a non-empty 'test' list. These are mutually exclusive: disable:true means 'no healthcheck', while test: defines one. When disabled, the converter emits a synthetic 'NONE' test and cannot also honor a user-supplied test.","triggerScenarios":"In docker-compose.yml: a service with healthcheck: { disable: true, test: [\"CMD\", \"curl\", \"-f\", \"http://localhost\"] }. The converter detects both set and aborts during 'docker compose' conversion (config -> engine mount/container spec).","commonSituations":"Editing a compose file: a developer disables a healthcheck but forgets to remove/comment the inherited test block. Templating tools that merge disable:true onto services that already define test. Overriding a base compose file's healthcheck with disable while the base keeps test.","solutions":["Decide intent: either remove 'disable: true' (to keep the test) or remove 'test:' (to disable).","If overriding a base file, set only one of disable/test in the override.","After editing, run 'docker compose config' to validate conversion before 'up'."],"exampleFix":"# before\nservices:\n  web:\n    healthcheck:\n      disable: true\n      test: [\"CMD\", \"curl\", \"-f\", \"http://localhost\"]\n\n# after (keep the test, drop disable)\nservices:\n  web:\n    healthcheck:\n      test: [\"CMD\", \"curl\", \"-f\", \"http://localhost\"]","handlingStrategy":"validation","validationCode":"// Validate a Compose healthcheck block before conversion.\nfunc validateHealthcheck(hc *composetypes.HealthCheckConfig) error {\n    if hc == nil {\n        return nil\n    }\n    if hc.Disable && len(hc.Test) != 0 {\n        return errors.New(\"healthcheck: 'disable' and 'test' are mutually exclusive\")\n    }\n    return nil\n}","typeGuard":"// healthcheckIsSelfConsistent reports whether disable/test are not both set.\nfunc healthcheckIsSelfConsistent(hc *composetypes.HealthCheckConfig) bool {\n    if hc == nil {\n        return true\n    }\n    return !(hc.Disable && len(hc.Test) != 0)\n}","tryCatchPattern":null,"preventionTips":["When disabling an inherited healthcheck, remove/comment the test block rather than adding disable.","Run 'docker compose config' in CI to catch conflicting healthcheck options early.","In override files, set exactly one of disable or test."],"tags":["docker-compose","healthcheck","validation","convert"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}