{"record":{"id":"f3035d87c04e6848","repo":"docker/cli","slug":"cannot-supply-extra-formatting-options-to-the-pret-f3035d","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/service/inspect.go","lineNumber":88,"sourceCode":"\t\tres, err := apiClient.NetworkInspect(ctx, ref, client.NetworkInspectOptions{Scope: \"swarm\"})\n\t\tif err == nil || !errdefs.IsNotFound(err) {\n\t\t\treturn res.Network, res.Raw, err\n\t\t}\n\t\treturn nil, nil, fmt.Errorf(\"no such network: %s\", ref)\n\t}\n\n\tf := opts.format\n\tif len(f) == 0 {\n\t\tf = \"raw\"\n\t\tif len(dockerCLI.ConfigFile().ServiceInspectFormat) > 0 {\n\t\t\tf = dockerCLI.ConfigFile().ServiceInspectFormat\n\t\t}\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(f, \"pretty\") && f != \"pretty\" {\n\t\treturn errors.New(\"cannot supply extra formatting options to the pretty template\")\n\t}\n\n\tserviceCtx := formatter.Context{\n\t\tOutput: dockerCLI.Out(),\n\t\tFormat: newFormat(f),\n\t}\n\n\tif err := inspectFormatWrite(serviceCtx, opts.refs, getRef, getNetwork); err != nil {\n\t\treturn cli.StatusError{StatusCode: 1, Status: err.Error()}\n\t}\n\treturn nil\n}\n","sourceCodeStart":70,"sourceCodeEnd":101,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/service/inspect.go#L70-L101","documentation":"Identical logic to error 100 but for `docker service inspect`. After resolving the effective format string `f` (from `--format`, or from the Docker config file's `ServiceInspectFormat`, or defaulting to \"raw\"), this error fires at service/inspect.go:87-88 if `f` starts with \"pretty\" but is not exactly \"pretty\". Unlike the secret command, the format can also originate from the config file (`dockerCLI.ConfigFile().ServiceInspectFormat`), so a corrupted config value can trigger this without any `--format` flag on the command line.","triggerScenarios":"Passing `--format \"pretty extra\"` on the command line; or having `ServiceInspectFormat` set to a value like `\"pretty foo\"` in the Docker config file (`~/.docker/config.json`) while not passing `--format` on the CLI (lines 78-83 show the config file value is used as fallback).","commonSituations":"A Docker config file was manually edited or corrupted with a malformed `ServiceInspectFormat` value. Or a user tries to extend the pretty template with additional fields.","solutions":["Use exactly `--format pretty` or a full Go template (no \"pretty\" prefix)","Check and fix the Docker config file (`~/.docker/config.json`) — look for a malformed `serviceInspectFormat` key and remove or correct it","Use `--pretty` instead of `--format pretty` to bypass the format-string logic entirely"],"exampleFix":"# before (command-line)\ndocker service inspect --format \"pretty {{.ID}}\" myservice\n\n# after\ndocker service inspect --pretty myservice\n\n# --- config file fix ---\n# before (~/.docker/config.json):\n# { \"serviceInspectFormat\": \"pretty extra\" }\n# after:\n# { \"serviceInspectFormat\": \"\" }","handlingStrategy":"validation","validationCode":"// Validate effective format including config file fallback\nfunc validateServiceFormat(format, configFormat string) error {\n    f := format\n    if len(f) == 0 {\n        f = configFormat\n    }\n    if strings.HasPrefix(f, \"pretty\") && f != \"pretty\" {\n        return fmt.Errorf(\"format %q is invalid: use 'pretty' exactly or a full Go template\", f)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check ~/.docker/config.json for a malformed serviceInspectFormat value when debugging unexpected format errors","Use --pretty instead of --format pretty to avoid the format-string validation entirely","In automation, always pass --format explicitly (even if just 'json') to override any config file default"],"tags":["docker","cli","service","formatting","go-template","config"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}