{"id":"5c396b8c752b97a9","repo":"docker/cli","slug":"could-not-fetch-unlock-key-w-5c396b","errorCode":null,"errorMessage":"could not fetch unlock key: %w","messagePattern":"could not fetch unlock key: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/swarm/unlock_key.go","lineNumber":75,"sourceCode":"\n\t\t_, err = apiClient.SwarmUpdate(ctx, client.SwarmUpdateOptions{\n\t\t\tVersion: res.Swarm.Version,\n\t\t\tSpec:    res.Swarm.Spec,\n\n\t\t\tRotateManagerUnlockKey: true,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif !opts.quiet {\n\t\t\t_, _ = fmt.Fprintln(dockerCLI.Out(), \"Successfully rotated manager unlock key.\")\n\t\t}\n\t}\n\n\tresp, err := apiClient.SwarmGetUnlockKey(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not fetch unlock key: %w\", err)\n\t}\n\n\tif resp.Key == \"\" {\n\t\treturn errors.New(\"no unlock key is set\")\n\t}\n\n\tif opts.quiet {\n\t\t_, _ = fmt.Fprintln(dockerCLI.Out(), resp.Key)\n\t\treturn nil\n\t}\n\n\tprintUnlockCommand(dockerCLI.Out(), resp.Key)\n\treturn nil\n}\n\nfunc printUnlockCommand(out io.Writer, unlockKey string) {\n\tif len(unlockKey) > 0 {\n\t\t_, _ = fmt.Fprintf(out, \"To unlock a swarm manager after it restarts, \"+","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/swarm/unlock_key.go#L57-L93","documentation":"Error \"could not fetch unlock key: %w\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/swarm/unlock_key.go:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}