{"id":"d3a6878b528eab76","repo":"docker/cli","slug":"failed-to-write-public-key-to-s-w","errorCode":null,"errorMessage":"failed to write public key to %s: %w","messagePattern":"failed to write public key to (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/docker-trust/trust/key_generate.go","lineNumber":129,"sourceCode":"\t\treturn pem.Block{}, err\n\t}\n\n\tpubKey := data.PublicKeyFromPrivate(privKey)\n\treturn pem.Block{\n\t\tType: \"PUBLIC KEY\",\n\t\tHeaders: map[string]string{\n\t\t\t\"role\": keyName,\n\t\t},\n\t\tBytes: pubKey.Public(),\n\t}, nil\n}\n\nfunc writePubKeyPEMToDir(pubPEM pem.Block, keyName, workingDir string) (string, error) {\n\t// Output the public key to a file in the CWD or specified dir\n\tpubFileName := strings.Join([]string{keyName, \"pub\"}, \".\")\n\tpubFilePath := filepath.Join(workingDir, pubFileName)\n\tif err := os.WriteFile(pubFilePath, pem.EncodeToMemory(&pubPEM), notary.PrivNoExecPerms); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to write public key to %s: %w\", pubFilePath, err)\n\t}\n\treturn pubFilePath, nil\n}\n","sourceCodeStart":111,"sourceCodeEnd":133,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cmd/docker-trust/trust/key_generate.go#L111-L133","documentation":"Error \"failed to write public key to %s: %w\" thrown in docker/cli.","triggerScenarios":"Thrown at cmd/docker-trust/trust/key_generate.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}