{"record":{"id":"4ab23e5b47aa0662","repo":"docker/cli","slug":"invalid-type-t-for-healthcheck-test","errorCode":null,"errorMessage":"invalid type %T for healthcheck.test","messagePattern":"invalid type %T for healthcheck\\.test","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/loader/loader.go","lineNumber":892,"sourceCode":"\t}\n\tpanic(fmt.Errorf(\"expected a map or a list, got %T: %#v\", mappingOrList, mappingOrList))\n}\n\nvar transformShellCommand TransformerFunc = func(value any) (any, error) {\n\tif str, ok := value.(string); ok {\n\t\treturn shlex.Split(str)\n\t}\n\treturn value, nil\n}\n\nvar transformHealthCheckTest TransformerFunc = func(data any) (any, error) {\n\tswitch value := data.(type) {\n\tcase string:\n\t\treturn append([]string{\"CMD-SHELL\"}, value), nil\n\tcase []any:\n\t\treturn value, nil\n\tdefault:\n\t\treturn value, fmt.Errorf(\"invalid type %T for healthcheck.test\", value)\n\t}\n}\n\nvar transformSize TransformerFunc = func(value any) (any, error) {\n\tswitch value := value.(type) {\n\tcase int:\n\t\treturn int64(value), nil\n\tcase string:\n\t\treturn units.RAMInBytes(value)\n\t}\n\tpanic(fmt.Errorf(\"invalid type for size %T\", value))\n}\n\nvar transformStringToDuration TransformerFunc = func(value any) (any, error) {\n\tswitch value := value.(type) {\n\tcase string:\n\t\td, err := time.ParseDuration(value)\n\t\tif err != nil {","sourceCodeStart":874,"sourceCodeEnd":910,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/loader/loader.go#L874-L910","documentation":"Thrown by transformHealthCheckTest for a service's `healthcheck.test`. It accepts a string (auto-wrapped as CMD-SHELL) or a list (CMD/CMD-SHELL + args). Any other type (map, int, bool) is rejected.","triggerScenarios":"A service defines `healthcheck: { test: { cmd: curl } }` (map) or `test: 1` instead of a string/list.","commonSituations":"Using a map form that compose doesn't support; templating that yields a non-string.","solutions":["Use a string: `healthcheck: { test: curl -f http://localhost }`.","Or a list: `healthcheck: { test: [CMD, curl, -f, http://localhost] }`."],"exampleFix":"# before\nweb:\n  healthcheck:\n    test:\n      cmd: curl\n# after\nweb:\n  healthcheck:\n    test: [\"CMD\", \"curl\", \"-f\", \"http://localhost\"]","handlingStrategy":"type-guard","validationCode":"func validateHealthcheckTest(test any) error {\n    switch test.(type) {\n    case string, []any:\n        return nil\n    default:\n        return fmt.Errorf(\"healthcheck.test must be string or list, got %T\", test)\n    }\n}","typeGuard":"func isHealthcheckTest(v any) bool {\n    switch v.(type) {\n    case string, []any:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Use a string (CMD-SHELL) or a list (CMD + args) for healthcheck.test.","Don't use a map form for test.","Lint with `docker compose config`."],"tags":["compose","healthcheck","type-mismatch","service"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}