{"record":{"id":"af8722e0b240facf","repo":"docker/compose","slug":"unsupported-format-q-af8722","errorCode":null,"errorMessage":"unsupported format %q","messagePattern":"unsupported format %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/compose/generate.go","lineNumber":83,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\tproject, err := backend.Generate(ctx, api.GenerateOptions{\n\t\tContainers:  containers,\n\t\tProjectName: opts.ProjectName,\n\t})\n\tif err != nil {\n\t\treturn err\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 fmt.Errorf(\"unsupported format %q\", opts.Format)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Println(string(content))\n\n\treturn nil\n}\n","sourceCodeStart":65,"sourceCodeEnd":92,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/cmd/compose/generate.go#L65-L92","documentation":"`docker compose generate` serializes the produced project with either MarshalJSON or MarshalYAML; the format switch's default branch rejects any `--format` value other than `json` or `yaml`.","triggerScenarios":"Running `docker compose generate --format toml <container>`, a typo like `yml`, or a pass-through variable with unexpected content.","commonSituations":"Same-family mistake as other --format flags: inconsistent casing (`YAML`), trailing whitespace from variable expansion, or expecting parity with other Docker CLI format values.","solutions":["Use `--format json` or `--format yaml` (default is yaml, so you may simply omit the flag).","Normalize any variable used for --format to lowercase without whitespace.","Post-process the JSON output with jq/yq if you need another format."],"exampleFix":"# before\ndocker compose generate --format yml web\n\n# after\ndocker compose generate --format yaml web","handlingStrategy":"validation","validationCode":"# bash\ncase \"${FORMAT:-yaml}\" in json|yaml) ;; *) echo \"format must be json|yaml\" >&2; exit 2;; esac\ndocker compose generate --format \"$FORMAT\" \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit --format when yaml (the default) is acceptable.","Reuse one validated FORMAT variable across all compose format flags."],"tags":["cli","generate","format","flags","validation"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}