{"id":"83516f7ed1a4807e","repo":"docker/cli","slug":"could-not-fetch-unlock-key-w","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/init.go","lineNumber":129,"sourceCode":"\tif err != nil {\n\t\tif strings.Contains(err.Error(), \"could not choose an IP address to advertise\") || strings.Contains(err.Error(), \"could not find the system's IP address\") {\n\t\t\treturn fmt.Errorf(\"%w - specify one with --advertise-addr\", err)\n\t\t}\n\t\treturn err\n\t}\n\n\t_, _ = fmt.Fprintf(dockerCLI.Out(), \"Swarm initialized: current node (%s) is now a manager.\\n\\n\", res.NodeID)\n\n\tif err := printJoinCommand(ctx, dockerCLI, res.NodeID, true, false); err != nil {\n\t\treturn err\n\t}\n\n\t_, _ = fmt.Fprintln(dockerCLI.Out(), \"To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.\")\n\n\tif opts.swarmOptions.autolock {\n\t\tresp, err := apiClient.SwarmGetUnlockKey(ctx)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not fetch unlock key: %w\", err)\n\t\t}\n\t\tprintUnlockCommand(dockerCLI.Out(), resp.Key)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":111,"sourceCodeEnd":136,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/swarm/init.go#L111-L136","documentation":"Error \"could not fetch unlock key: %w\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/swarm/init.go:129 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}