{"record":{"id":"6cb346b3f4bb1f0b","repo":"netbirdio/netbird","slug":"write-public-key-file-s-w","errorCode":null,"errorMessage":"write public key file (%s): %w","messagePattern":"write public key file \\((.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/signer/artifactkey.go","lineNumber":120,"sourceCode":"\t\treturn fmt.Errorf(\"read root private key file: %w\", err)\n\t}\n\n\tprivateRootKey, err := reposign.ParseRootKey(privKeyPEM)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to parse private root key: %w\", err)\n\t}\n\n\tartifactKey, privPEM, pubPEM, signature, err := reposign.GenerateArtifactKey(privateRootKey, expiration)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"generate artifact key: %w\", err)\n\t}\n\n\tif err := os.WriteFile(artifactPrivKeyFile, privPEM, 0o600); err != nil {\n\t\treturn fmt.Errorf(\"write private key file (%s): %w\", artifactPrivKeyFile, err)\n\t}\n\n\tif err := os.WriteFile(artifactPubKeyFile, pubPEM, 0o600); err != nil {\n\t\treturn fmt.Errorf(\"write public key file (%s): %w\", artifactPubKeyFile, err)\n\t}\n\n\tsignatureFile := artifactPubKeyFile + \".sig\"\n\tif err := os.WriteFile(signatureFile, signature, 0o600); err != nil {\n\t\treturn fmt.Errorf(\"write signature file (%s): %w\", signatureFile, err)\n\t}\n\n\tcmd.Printf(\"✅ Artifact key created successfully.\\n\")\n\tcmd.Printf(\"%s\\n\", artifactKey.String())\n\treturn nil\n}\n\nfunc handleBundlePubKeys(cmd *cobra.Command, rootPrivKeyFile string, artifactPubKeyFiles []string, bundlePubKeysFile string) error {\n\tcmd.Println(\"📦 Bundling public keys into signed package...\")\n\n\tprivKeyPEM, err := os.ReadFile(rootPrivKeyFile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"read root private key file: %w\", err)","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/signer/artifactkey.go#L102-L138","documentation":"os.WriteFile failed while writing the artifact public key to --artifact-pub-key-file with mode 0600. Same failure class as the private key write: missing parent directory, permission denied, read-only filesystem, or ENOSPC.","triggerScenarios":"create-artifact-key where the public key output path is invalid or unwritable while earlier steps (key generation) already succeeded; note the private key file may already have been written, leaving partial output.","commonSituations":"Different parent directories for priv/pub outputs where only one exists; a typo only in the pub path; unwritable output dir in CI.","solutions":["Verify the parent directory of --artifact-pub-key-file exists and is writable","Use an absolute path to rule out relative-path/working-directory mistakes","If the run half-completed, delete the stale private key file and rerun both writes cleanly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for _, p := range []string{artifactPrivKeyFile, artifactPubKeyFile, artifactPubKeyFile + \".sig\"} {\n    if err := os.MkdirAll(filepath.Dir(p), 0o700); err != nil { ... }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use one output directory for all three files (priv, pub, .sig) and create it up front","Prefer absolute paths in CI to avoid relative-path drift","Clean partial outputs from failed runs before retrying"],"tags":["cli","file-io","permissions","go"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}