{"record":{"id":"1e046f9c2a9dbf70","repo":"docker/compose","slug":"unsupported-format-q","errorCode":null,"errorMessage":"unsupported format %q","messagePattern":"unsupported format %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/compose/config.go","lineNumber":250,"sourceCode":"\t\terr := project.CheckContainerNameUnicity()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif opts.lockImageDigests {\n\t\twarnHooksNotLockable(project)\n\t\tproject = imagesOnly(project)\n\t}\n\n\tvar content []byte\n\tswitch opts.Format {\n\tcase \"json\":\n\t\tcontent, err = project.MarshalJSON()\n\tcase \"yaml\":\n\t\tcontent, err = project.MarshalYAML()\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported format %q\", opts.Format)\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn content, nil\n}\n\n// imagesOnly return project with all attributes removed but service.images and `type: image` volumes\nfunc imagesOnly(project *types.Project) *types.Project {\n\tdigests := types.Services{}\n\tfor name, config := range project.Services {\n\t\tservice := types.ServiceConfig{\n\t\t\tImage: config.Image,\n\t\t}\n\t\tfor _, vol := range config.Volumes {\n\t\t\tif vol.Type == types.VolumeTypeImage {\n\t\t\t\tservice.Volumes = append(service.Volumes, vol)\n\t\t\t}","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/cmd/compose/config.go#L232-L268","documentation":"The `docker compose config` command only supports serialization of the resolved project to `json` or `yaml`. The format switch in cmd/compose/config.go hits its default branch when opts.Format is anything else, including an unset-but-customized value.","triggerScenarios":"Running `docker compose config --format toml` (or any string other than json/yaml). Also possible when a wrapper script passes `--format` from an unvalidated variable.","commonSituations":"Scripts migrating from `docker-compose config` output processing that assume other formats; typos like `--format yml` (the accepted value is `yaml`); automation passing a format flag through without validation.","solutions":["Use `--format json` or `--format yaml` exactly (note: `yml` is not accepted).","If you need TOML or another format, output `--format json` and convert with an external tool such as yq/jq.","Validate the variable feeding `--format` in your wrapper script before invoking compose."],"exampleFix":"# before\ndocker compose config --format yml\n\n# after\ndocker compose config --format yaml","handlingStrategy":"validation","validationCode":"# bash\ncase \"$FORMAT\" in json|yaml) ;; *) echo \"--format must be json|yaml, got '$FORMAT'\" >&2; exit 2;; esac\ndocker compose config --format \"$FORMAT\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize format selection in one variable validated against json|yaml.","Prefer json output for machine consumption; convert formats downstream."],"tags":["cli","config","format","flags","validation"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}