{"record":{"id":"832b27018c5fb41f","repo":"docker/cli","slug":"cannot-supply-extra-formatting-options-to-the-pret","errorCode":null,"errorMessage":"cannot supply extra formatting options to the pretty template","messagePattern":"cannot supply extra formatting options to the pretty template","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/config/inspect.go","lineNumber":61,"sourceCode":"}\n\n// runInspect inspects the given Swarm config.\nfunc runInspect(ctx context.Context, dockerCLI command.Cli, opts inspectOptions) error {\n\tapiClient := dockerCLI.Client()\n\n\tif opts.pretty {\n\t\topts.format = \"pretty\"\n\t}\n\n\tgetRef := func(id string) (any, []byte, error) {\n\t\tres, err := apiClient.ConfigInspect(ctx, id, client.ConfigInspectOptions{})\n\t\treturn res.Config, res.Raw, err\n\t}\n\n\t// check if the user is trying to apply a template to the pretty format, which\n\t// is not supported\n\tif strings.HasPrefix(opts.format, \"pretty\") && opts.format != \"pretty\" {\n\t\treturn errors.New(\"cannot supply extra formatting options to the pretty template\")\n\t}\n\n\tconfigCtx := formatter.Context{\n\t\tOutput: dockerCLI.Out(),\n\t\tFormat: newFormat(opts.format, false),\n\t}\n\n\tif err := inspectFormatWrite(configCtx, opts.names, getRef); err != nil {\n\t\treturn cli.StatusError{StatusCode: 1, Status: err.Error()}\n\t}\n\treturn nil\n}\n","sourceCodeStart":43,"sourceCodeEnd":74,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/config/inspect.go#L43-L74","documentation":"runInspect for `docker config inspect` (cli/command/config/inspect.go:46) special-cases the 'pretty' format. If opts.format begins with the literal \"pretty\" but is not exactly \"pretty\" (e.g. 'pretty {{.x}}'), it returns errors.New(\"cannot supply extra formatting options to the pretty template\") at line 61. The pretty formatter is fixed and does not accept Go template directives.","triggerScenarios":"Running `docker config inspect --pretty --format 'pretty {{.ID}}' NAME` or `docker config inspect -f 'pretty-extra' NAME`. The --pretty flag sets format to exactly \"pretty\"; the error arises only when the user manually supplies a --format string that starts with 'pretty' but continues with template text.","commonSituations":"Users assuming 'pretty' is a template prefix to which they can append fields; typos like 'pretty{{.ID}}'; copy-pasting a format from another inspect command.","solutions":["Use --pretty alone for the human-friendly view, OR use --format with a pure Go template (without the 'pretty' prefix) for custom output.","If you want templated fields, drop 'pretty': `docker config inspect -f '{{.ID}} {{.Spec.Name}}' NAME`.","Do not combine --pretty with a custom --format string."],"exampleFix":"# before\ndocker config inspect -f 'pretty {{.ID}}' mycfg\n# after — either use pretty alone, or a real template\ndocker config inspect --pretty mycfg\n# or\ndocker config inspect -f '{{.ID}} {{.Spec.Name}}' mycfg","handlingStrategy":"validation","validationCode":"// Normalize the format before runInspect:\nif strings.HasPrefix(format, \"pretty\") && format != \"pretty\" {\n    // either strip to \"pretty\" or reject with guidance\n    return errors.New(\"'pretty' cannot be combined with template directives\")\n}","typeGuard":null,"tryCatchPattern":"if err := runInspect(ctx, cli, opts); err != nil {\n    if strings.Contains(err.Error(), \"cannot supply extra formatting options to the pretty template\") {\n        // tell user to use --pretty alone or a plain template\n    }\n    return err\n}","preventionTips":["Do not combine --pretty with a custom --format string.","Use a plain Go template (no 'pretty' prefix) for custom fields.","Document the two mutually exclusive formatting modes for your team."],"tags":["config","swarm","format","template","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}