{"record":{"id":"cef89542dec4c8a7","repo":"slackhq/nebula","slug":"error-while-writing-out-qr-s-cef895","errorCode":null,"errorMessage":"error while writing out-qr: %s","messagePattern":"error while writing out-qr: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/nebula-cert/sign.go","lineNumber":421,"sourceCode":"\t\t\treturn fmt.Errorf(\"error while marshalling certificate: %s\", err)\n\t\t}\n\t\tb = append(b, sb...)\n\t}\n\n\terr = writeOutput(*sf.outCertPath, b, 0600, out)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error while writing out-crt: %s\", err)\n\t}\n\n\tif *sf.outQRPath != \"\" {\n\t\tb, err = qrcode.Encode(string(b), qrcode.Medium, -5)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error while generating qr code: %s\", err)\n\t\t}\n\n\t\terr = writeOutput(*sf.outQRPath, b, 0600, out)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error while writing out-qr: %s\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc newKeypair(curve cert.Curve) ([]byte, []byte) {\n\tswitch curve {\n\tcase cert.Curve_CURVE25519:\n\t\treturn x25519Keypair()\n\tcase cert.Curve_P256:\n\t\treturn p256Keypair()\n\tdefault:\n\t\treturn nil, nil\n\t}\n}\n\nfunc x25519Keypair() ([]byte, []byte) {","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/cmd/nebula-cert/sign.go#L403-L439","documentation":"After the QR PNG bytes are generated, signCert writes them to the -out-qr path with writeOutput. A failure here (bad path, permissions, disk full) is wrapped as 'error while writing out-qr'; the certificate file itself has already been written successfully at this point.","triggerScenarios":"writeOutput(*sf.outQRPath, b, 0600, out) returns an error while writing the QR PNG — non-existent directory, unwritable path, or stdout writer failure.","commonSituations":"-out-qr path typo; destination directory missing; no write permission; disk full on embedded devices.","solutions":["Check the -out-qr path's directory exists and is writable","Free disk space or choose another output location","If not needed, omit -out-qr entirely — the cert file is already written"],"exampleFix":"// before\n./nebula-cert sign -ca ca.pem -key ca.key -name host -out-crt host.crt -out-qr /read-only/qr.png\n// after\n./nebula-cert sign -ca ca.pem -key ca.key -name host -out-crt host.crt -out-qr ./qr.png","handlingStrategy":"validation","validationCode":"import \"os\"\nfunc ensureWritable(path string) error {\n    dir := filepath.Dir(path)\n    fi, err := os.Stat(dir)\n    if err != nil || !fi.IsDir() {\n        return fmt.Errorf(\"bad dir %s\", dir)\n    }\n    f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, 0600)\n    if err != nil { return err }\n    return f.Close()\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Run(); err != nil {\n    if strings.Contains(err.Error(), \"error while writing out-qr\") {\n        log.Printf(\"QR write failed (cert already written): %v\", err)\n    }\n}","preventionTips":["Check disk space before signing on small devices","Ensure -out-qr directory exists and is writable","Omit -out-qr when not needed"],"tags":["go","cli","filesystem","file-write"],"backgroundTag":"file-write-failed","analyzedSha":"dd8f660c0ac37903ec4080ca4d3c861ba9342ceb","analyzedAt":"2026-09-03T11:13:55.444Z","contentChangedAt":"2026-09-03T11:13:55.444Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}