{"record":{"id":"1d6696bec77e3bbc","repo":"docker/cli","slug":"cannot-supply-extra-formatting-options-to-the-pret-1d6696","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/secret/inspect.go","lineNumber":59,"sourceCode":"\treturn cmd\n}\n\nfunc runSecretInspect(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.SecretInspect(ctx, id, client.SecretInspectOptions{})\n\t\treturn res.Secret, 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\tsecretCtx := formatter.Context{\n\t\tOutput: dockerCLI.Out(),\n\t\tFormat: newFormat(opts.format, false),\n\t}\n\n\tif err := inspectFormatWrite(secretCtx, opts.names, getRef); err != nil {\n\t\treturn cli.StatusError{StatusCode: 1, Status: err.Error()}\n\t}\n\treturn nil\n}\n","sourceCodeStart":41,"sourceCodeEnd":72,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/secret/inspect.go#L41-L72","documentation":"The `docker secret inspect` command offers a built-in \"pretty\" template for human-readable output (set via the `--pretty` flag or `--format pretty`). This error fires at secret/inspect.go:58-59 when the resolved format string starts with \"pretty\" but is not exactly \"pretty\", meaning the user attempted to append Go template directives to the predefined pretty template (e.g., `--format \"pretty {{.ID}}\"`). The pretty format is a fixed, opaque template and cannot be combined with custom Go template expressions.","triggerScenarios":"Running `docker secret inspect --format \"pretty {{.ID}}\" mysecret` or any invocation where `opts.format` is set to a string with the prefix \"pretty\" followed by additional characters. Note: using `--pretty` alone is safe because line 48 sets `opts.format` to exactly `\"pretty\"`, which passes the check.","commonSituations":"A developer assumes \"pretty\" is a composable base template and tries to add fields to it, e.g., `--format \"pretty some-extra\"`. Or a wrapper script constructs a format string by concatenating \"pretty\" with template fragments.","solutions":["Use `--pretty` alone (no --format) for the built-in human-friendly output","Use `--format` with a complete Go template from scratch (e.g., `--format \"{{json .}}\"`), omitting the \"pretty\" prefix","Use `--format pretty` (exactly the word \"pretty\" with no trailing characters) as an alternative to --pretty"],"exampleFix":"# before\ndocker secret inspect --format \"pretty {{.ID}}\" mysecret\n\n# after (option A: built-in pretty)\ndocker secret inspect --pretty mysecret\n\n# after (option B: custom Go template)\ndocker secret inspect --format \"{{json .}}\" mysecret","handlingStrategy":"validation","validationCode":"// Validate before calling runSecretInspect\nfunc validateSecretFormat(format string, pretty bool) error {\n    effective := format\n    if pretty {\n        effective = \"pretty\"\n    }\n    if strings.HasPrefix(effective, \"pretty\") && effective != \"pretty\" {\n        return fmt.Errorf(\"format %q is invalid: use 'pretty' exactly or a full Go template\", effective)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never concatenate 'pretty' with template fragments — it is an opaque keyword, not a base template","Use --pretty for human output or --format with a standalone Go template — never both patterns","If building format strings programmatically, validate that the value is either exactly 'pretty' or does not start with 'pretty'"],"tags":["docker","cli","secret","formatting","go-template"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}