{"record":{"id":"8ce01d32b97bfe5c","repo":"docker/cli","slug":"other-flags-may-not-be-combined-with-rollback","errorCode":null,"errorMessage":"other flags may not be combined with --rollback","messagePattern":"other flags may not be combined with --rollback","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/service/update.go","lineNumber":180,"sourceCode":"\n\trollback, err := flags.GetBool(flagRollback)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif rollback {\n\t\t// Rollback can't be combined with other flags.\n\t\totherFlagsPassed := false\n\t\tflags.VisitAll(func(f *pflag.Flag) {\n\t\t\tif f.Name == flagRollback || f.Name == flagDetach || f.Name == flagQuiet {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif flags.Changed(f.Name) {\n\t\t\t\totherFlagsPassed = true\n\t\t\t}\n\t\t})\n\t\tif otherFlagsPassed {\n\t\t\treturn errors.New(\"other flags may not be combined with --rollback\")\n\t\t}\n\t}\n\n\tupdateOpts := client.ServiceUpdateOptions{}\n\trollbackAction := \"none\"\n\tif rollback {\n\t\trollbackAction = \"previous\"\n\t}\n\n\tspec := &res.Service.Spec\n\terr = updateService(ctx, apiClient, flags, spec)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif flags.Changed(\"image\") {\n\t\tupdateOpts.QueryRegistry = !options.noResolveImage\n\t}","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/service/update.go#L162-L198","documentation":"Thrown by runUpdate (cli/command/service/update.go:180) when `--rollback` is combined with any other changed mutating flag. Only `--rollback`, `--detach`, and `--quiet` are exempt. Rollback restores the entire previous spec wholesale, so partial edits alongside it would be self-contradictory and are rejected up front.","triggerScenarios":"Invoking `docker service update --rollback <other-flag> <svc>` where the other flag's Changed bit is set, e.g. `docker service update --rollback --image nginx:alpine web`. The VisitAll loop sets otherFlagsPassed=true and the error fires.","commonSituations":"An operator tries to roll back and simultaneously tweak an option in one shot; a CI script concatenates a rollback with environment or image flags; alias/wrapper scripts always append extra flags.","solutions":["Run rollback as its own command with no mutating flags: `docker service update --rollback <svc>`.","Apply other changes in a separate subsequent `docker service update` call after the rollback converges.","Audit wrapper scripts that blanket-append flags to every update invocation."],"exampleFix":"// before\ndocker service update --rollback --env-add FOO=bar web\n\n// after\ndocker service update --rollback web\ndocker service update --env-add FOO=bar web","handlingStrategy":"validation","validationCode":"// Reject rollback+other-flags before calling the API.\nrollback, _ := flags.GetBool(flagRollback)\nif rollback {\n\tvar extra []string\n\tflags.VisitAll(func(f *pflag.Flag) {\n\t\tif f.Name != flagRollback && f.Name != flagDetach && f.Name != flagQuiet && flags.Changed(f.Name) {\n\t\t\textra = append(extra, f.Name)\n\t\t}\n\t})\n\tif len(extra) > 0 {\n\t\treturn fmt.Errorf(\"--rollback must run alone; drop: %s\", strings.Join(extra, \", \"))\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Issue rollback as a dedicated command, never bundled with edits.","In wrapper scripts, default to two-step: rollback, then edit.","Warn in CI when a rollback flag is combined with mutating flags."],"tags":["docker","swarm","service","rollback","flags","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}