{"record":{"id":"5fe0ed38757de63a","repo":"docker/cli","slug":"format-is-incompatible-with-human-friendly-forma","errorCode":null,"errorMessage":"--format is incompatible with human friendly format","messagePattern":"--format is incompatible with human friendly format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/service/inspect.go","lineNumber":38,"sourceCode":"\ntype inspectOptions struct {\n\trefs   []string\n\tformat string\n\tpretty bool\n}\n\nfunc newInspectCommand(dockerCLI command.Cli) *cobra.Command {\n\tvar opts inspectOptions\n\n\tcmd := &cobra.Command{\n\t\tUse:   \"inspect [OPTIONS] SERVICE [SERVICE...]\",\n\t\tShort: \"Display detailed information on one or more services\",\n\t\tArgs:  cli.RequiresMinArgs(1),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\topts.refs = args\n\n\t\t\tif opts.pretty && len(opts.format) > 0 {\n\t\t\t\treturn errors.New(\"--format is incompatible with human friendly format\")\n\t\t\t}\n\t\t\treturn runInspect(cmd.Context(), dockerCLI, opts)\n\t\t},\n\t\tValidArgsFunction:     completeServiceNames(dockerCLI),\n\t\tDisableFlagsInUseLine: true,\n\t}\n\n\tflags := cmd.Flags()\n\tflags.StringVarP(&opts.format, \"format\", \"f\", \"\", flagsHelper.InspectFormatHelp)\n\tflags.BoolVar(&opts.pretty, \"pretty\", false, \"Print the information in a human friendly format\")\n\n\treturn cmd\n}\n\nfunc runInspect(ctx context.Context, dockerCLI command.Cli, opts inspectOptions) error {\n\tapiClient := dockerCLI.Client()\n\n\tif opts.pretty {","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/service/inspect.go#L20-L56","documentation":"In `docker service inspect`, the `--pretty` and `--format` flags are mutually exclusive — `--pretty` selects the built-in human-readable template while `--format` selects a user-supplied Go template. This error fires at service/inspect.go:37-38 when both flags are set simultaneously (`opts.pretty == true && len(opts.format) > 0`). The check runs in the command's RunE before any API call is made.","triggerScenarios":"Running `docker service inspect --pretty --format \"{{.ID}}\" myservice` where both `--pretty` is true and `--format` has a non-empty value. Also triggered if a shell alias or wrapper always appends `--format` and the user adds `--pretty`.","commonSituations":"A developer has a Docker config or shell alias that sets `--format` globally, then tries to use `--pretty` for a quick human-readable check. Or a CI script hardcodes `--format json` and an operator overrides with `--pretty`.","solutions":["Remove `--pretty` when using `--format` (they conflict by design)","Remove `--format` when using `--pretty`","Use `--format pretty` (exactly the word) instead of `--pretty` to get human-friendly output without the flag conflict"],"exampleFix":"# before\ndocker service inspect --pretty --format \"{{.ID}}\" myservice\n\n# after (custom template)\ndocker service inspect --format \"{{.ID}}\" myservice\n\n# after (human-friendly)\ndocker service inspect --pretty myservice","handlingStrategy":"validation","validationCode":"// Validate mutual exclusivity before invoking the command\nfunc validateServiceInspectOpts(format string, pretty bool) error {\n    if pretty && len(format) > 0 {\n        return errors.New(\"--pretty and --format are mutually exclusive\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --pretty and --format as mutually exclusive in all wrapper scripts","If you have a global --format alias, use `--format pretty` instead of --pretty to avoid the conflict path","Document which output mode each script/alias uses to prevent accidental mixing"],"tags":["docker","cli","service","formatting","flag-conflict"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}