{"record":{"id":"093efde16d2b9771","repo":"docker/cli","slug":"invalid-option-s-for-flag-resolve-image","errorCode":null,"errorMessage":"invalid option %s for flag --resolve-image","messagePattern":"invalid option (.+?) for flag --resolve-image","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/stack/deploy.go","lineNumber":86,"sourceCode":"\treturn cmd\n}\n\n// Resolve image constants\nconst (\n\tresolveImageAlways  = \"always\"\n\tresolveImageChanged = \"changed\"\n\tresolveImageNever   = \"never\"\n)\n\nconst defaultNetworkDriver = \"overlay\"\n\n// runDeploy is the swarm implementation of docker stack deploy\nfunc runDeploy(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opts *deployOptions, cfg *composetypes.Config) error {\n\tswitch opts.resolveImage {\n\tcase resolveImageAlways, resolveImageChanged, resolveImageNever:\n\t\t// valid options.\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid option %s for flag --resolve-image\", opts.resolveImage)\n\t}\n\n\tif opts.detach && !flags.Changed(\"detach\") {\n\t\t_, _ = fmt.Fprintln(dockerCLI.Err(), \"Since --detach=false was not specified, tasks will be created in the background.\\n\"+\n\t\t\t\"In a future release, --detach=false will become the default.\")\n\t}\n\n\treturn deployCompose(ctx, dockerCLI, opts, cfg)\n}\n\n// checkDaemonIsSwarmManager does an Info API call to verify that the daemon is\n// a swarm manager. This is necessary because we must create networks before we\n// create services, but the API call for creating a network does not return a\n// proper status code when it can't create a network in the \"global\" scope.\nfunc checkDaemonIsSwarmManager(ctx context.Context, dockerCli command.Cli) error {\n\tres, err := dockerCli.Client().Info(ctx, client.InfoOptions{})\n\tif err != nil {\n\t\treturn err","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/stack/deploy.go#L68-L104","documentation":"Raised by runDeploy when the --resolve-image flag value is not one of the three allowed constants: always, changed, or never. This flag controls whether/how the registry is queried to resolve image digests during stack deploy.","triggerScenarios":"Running `docker stack deploy --resolve-image <value>` where <value> is anything other than 'always', 'changed', or 'never'. The switch at deploy.go:82 falls through to the default branch. This typically happens only with typos or direct API/library calls since cobra flag validation usually catches it earlier.","commonSituations":"Typo like 'allways', 'chagned', 'true', or 'on'; passing a value sourced from a config/env var without validation; older docs referencing a removed/renamed option.","solutions":["Use exactly one of: --resolve-image=always, --resolve-image=changed, or --resolve-image=never.","If sourcing the value from a variable, validate it against the allowed set before invoking deploy.","Check the Docker CLI version docs to confirm the option set hasn't changed."],"exampleFix":"// before\ndocker stack deploy --resolve-image allways mystack -c compose.yml\n// after\ndocker stack deploy --resolve-image always mystack -c compose.yml","handlingStrategy":"validation","validationCode":"var validResolveImage = map[string]struct{}{\"always\": {}, \"changed\": {}, \"never\": {}}\n\nfunc resolveImageOpt(v string) error {\n    if _, ok := validResolveImage[v]; !ok {\n        return fmt.Errorf(\"invalid --resolve-image value %q; want always|changed|never\", v)\n    }\n    return nil\n}","typeGuard":"type ResolveImage string\n\nconst (\n    ResolveAlways  ResolveImage = \"always\"\n    ResolveChanged ResolveImage = \"changed\"\n    ResolveNever   ResolveImage = \"never\"\n)\n\nfunc (r ResolveImage) Valid() bool {\n    switch r {\n    case ResolveAlways, ResolveChanged, ResolveNever:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Type the option as a Go enum/const so invalid values can't be constructed.","Validate config-sourced values against the allowed set before invoking deploy.","Document the three options wherever the flag is exposed."],"tags":["docker","stack","deploy","flag","image-resolution"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}