{"record":{"id":"96cef51053663af9","repo":"docker/cli","slug":"invalid-type-t-for-service-build","errorCode":null,"errorMessage":"invalid type %T for service build","messagePattern":"invalid type %T for service build","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/loader/loader.go","lineNumber":758,"sourceCode":"var transformStringSourceMap TransformerFunc = func(data any) (any, error) {\n\tswitch value := data.(type) {\n\tcase string:\n\t\treturn map[string]any{\"source\": value}, nil\n\tcase map[string]any:\n\t\treturn data, nil\n\tdefault:\n\t\treturn data, fmt.Errorf(\"invalid type %T for secret\", value)\n\t}\n}\n\nvar transformBuildConfig TransformerFunc = func(data any) (any, error) {\n\tswitch value := data.(type) {\n\tcase string:\n\t\treturn map[string]any{\"context\": value}, nil\n\tcase map[string]any:\n\t\treturn data, nil\n\tdefault:\n\t\treturn data, fmt.Errorf(\"invalid type %T for service build\", value)\n\t}\n}\n\nvar transformServiceVolumeConfig TransformerFunc = func(data any) (any, error) {\n\tswitch value := data.(type) {\n\tcase string:\n\t\treturn volumespec.Parse(value)\n\tcase map[string]any:\n\t\treturn data, nil\n\tdefault:\n\t\treturn data, fmt.Errorf(\"invalid type %T for service volume\", value)\n\t}\n}\n\nvar transformServiceNetworkMap TransformerFunc = func(value any) (any, error) {\n\tif list, ok := value.([]any); ok {\n\t\tmapValue := map[any]any{}\n\t\tfor _, name := range list {","sourceCodeStart":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/loader/loader.go#L740-L776","documentation":"Thrown by transformBuildConfig, the transformer for a service's `build` field. It accepts a string (context path) or a map (full build config with context/args/dockerfile). Any other type (list, int, bool) is rejected.","triggerScenarios":"A service defines `build:` as a list (`build: [., Dockerfile]`) or a scalar number/bool.","commonSituations":"Mis-indenting the build block into a list; templating that yields a non-string/map.","solutions":["Use a string context: `build: .`","Or a map: `build: { context: ., dockerfile: Dockerfile }`."],"exampleFix":"# before\nweb:\n  build:\n    - .\n    - Dockerfile\n# after\nweb:\n  build:\n    context: .\n    dockerfile: Dockerfile","handlingStrategy":"type-guard","validationCode":"func validateBuild(build any) error {\n    switch build.(type) {\n    case string, map[string]any:\n        return nil\n    default:\n        return fmt.Errorf(\"build must be string or map, got %T\", build)\n    }\n}","typeGuard":"func isValidBuild(v any) bool {\n    switch v.(type) {\n    case string, map[string]any:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Use `build: <context>` or a `build: { context: ..., dockerfile: ... }` map.","Don't turn the build block into a list.","Render with `docker compose config`."],"tags":["compose","build","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"}