{"record":{"id":"0902a8bbf803d1ec","repo":"docker/cli","slug":"invalid-type-t-for-service-volume","errorCode":null,"errorMessage":"invalid type %T for service volume","messagePattern":"invalid type %T for service volume","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/loader/loader.go","lineNumber":769,"sourceCode":"var 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 {\n\t\t\tmapValue[name] = nil\n\t\t}\n\t\treturn mapValue, nil\n\t}\n\treturn value, nil\n}\n\nvar transformStringOrNumberList TransformerFunc = func(value any) (any, error) {\n\tlist := value.([]any)\n\tresult := make([]string, len(list))\n\tfor i, item := range list {","sourceCodeStart":751,"sourceCodeEnd":787,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/loader/loader.go#L751-L787","documentation":"Thrown by transformServiceVolumeConfig, the transformer for one entry of a service's `volumes` list. Each entry must be a string (short syntax `src:tgt:mode`) or a map (long form). Any other type is rejected.","triggerScenarios":"A `volumes:` list contains an int, bool, nested list, or null instead of a string/map entry.","commonSituations":"Bad indentation turning a long-form map into a scalar; templating that emits empty entries.","solutions":["Use the short string form: `volumes: [\"./data:/data\"]`.","Or the long map form: `volumes: [ { type: bind, source: ./data, target: /data } ]`."],"exampleFix":"# before\nweb:\n  volumes:\n    - ./data\n      /data\n# after\nweb:\n  volumes:\n    - \"./data:/data\"","handlingStrategy":"type-guard","validationCode":"func validateVolumeEntries(volumes any) error {\n    list, ok := volumes.([]any)\n    if !ok {\n        return nil\n    }\n    for i, e := range list {\n        switch e.(type) {\n        case string, map[string]any:\n        default:\n            return fmt.Errorf(\"volumes[%d]: invalid type %T\", i, e)\n        }\n    }\n    return nil\n}","typeGuard":"func isVolumeEntry(v any) bool {\n    switch v.(type) {\n    case string, map[string]any:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Each volumes entry is a string (short) or map (long).","Keep long-form maps on one indented block per entry.","Lint with `docker compose config`."],"tags":["compose","volume","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"}