netbirdio/netbird · error
write public key file (%s): %w
Error message
write public key file (%s): %w
What it means
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.
Source
Thrown at client/cmd/signer/artifactkey.go:120
return fmt.Errorf("read root private key file: %w", err)
}
privateRootKey, err := reposign.ParseRootKey(privKeyPEM)
if err != nil {
return fmt.Errorf("failed to parse private root key: %w", err)
}
artifactKey, privPEM, pubPEM, signature, err := reposign.GenerateArtifactKey(privateRootKey, expiration)
if err != nil {
return fmt.Errorf("generate artifact key: %w", err)
}
if err := os.WriteFile(artifactPrivKeyFile, privPEM, 0o600); err != nil {
return fmt.Errorf("write private key file (%s): %w", artifactPrivKeyFile, err)
}
if err := os.WriteFile(artifactPubKeyFile, pubPEM, 0o600); err != nil {
return fmt.Errorf("write public key file (%s): %w", artifactPubKeyFile, err)
}
signatureFile := artifactPubKeyFile + ".sig"
if err := os.WriteFile(signatureFile, signature, 0o600); err != nil {
return fmt.Errorf("write signature file (%s): %w", signatureFile, err)
}
cmd.Printf("✅ Artifact key created successfully.\n")
cmd.Printf("%s\n", artifactKey.String())
return nil
}
func handleBundlePubKeys(cmd *cobra.Command, rootPrivKeyFile string, artifactPubKeyFiles []string, bundlePubKeysFile string) error {
cmd.Println("📦 Bundling public keys into signed package...")
privKeyPEM, err := os.ReadFile(rootPrivKeyFile)
if err != nil {
return fmt.Errorf("read root private key file: %w", err)View on GitHub (pinned to 93e97f4bf1)
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
Defensive patterns
Strategy: validation
Validate before calling
for _, p := range []string{artifactPrivKeyFile, artifactPubKeyFile, artifactPubKeyFile + ".sig"} {
if err := os.MkdirAll(filepath.Dir(p), 0o700); err != nil { ... }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Different parent directories for priv/pub outputs where only one exists; a typo only in the pub path; unwritable output dir in CI.
Related errors
- write private key file (%s): %w
- write public keys file (%s): %w
- failed to write output files: %w
- failed to write revocation list file: %w
- failed to write signature file: %w
AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16).
Data as JSON: /api/errors/6cb346b3f4bb1f0b.
Report an issue: GitHub.