{"record":{"id":"a48893572c3923fb","repo":"slackhq/nebula","slug":"error-while-writing-out-qr-s","errorCode":null,"errorMessage":"error while writing out-qr: %s","messagePattern":"error while writing out-qr: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/nebula-cert/ca.go","lineNumber":372,"sourceCode":"\tb, err = c.MarshalPEM()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error while marshalling certificate: %s\", err)\n\t}\n\n\terr = writeOutput(*cf.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 *cf.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(*cf.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 caSummary() string {\n\treturn \"ca <flags>: create a self signed certificate authority\"\n}\n\nfunc caHelp(out io.Writer) {\n\tcf := newCaFlags()\n\tout.Write([]byte(\"Usage of \" + os.Args[0] + \" \" + caSummary() + \"\\n\"))\n\tout.Write([]byte(stdioHelpText))\n\tcf.set.SetOutput(out)\n\tcf.set.PrintDefaults()\n}\n","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/cmd/nebula-cert/ca.go#L354-L390","documentation":"nebula-cert's `ca` subcommand failed while writing the generated QR code PNG to the path given via -out-qr. QR encoding succeeded but writeOutput to disk failed; the underlying error is embedded in the message.","triggerScenarios":"Running `nebula-cert ca -out-qr <path>` where writeOutput(*cf.outQRPath, b, 0600, out) fails: parent directory missing, permission denied, disk full, or path is a directory.","commonSituations":"Typo in -out-qr path; read-only output directory; non-root user lacking write access; the QR target path pointing at an existing directory.","solutions":["Verify the -out-qr directory exists and is writable (mkdir -p).","Ensure the -out-qr path is a file path, not a directory.","Check disk space and filesystem mount options (read-only).","Rerun without -out-qr if the QR image is not needed."],"exampleFix":"// before\nnebula-cert ca -name org -out-qr /qr/ca-qr.png\n// after\nmkdir -p /qr && nebula-cert ca -name org -out-qr /qr/ca-qr.png","handlingStrategy":"try-catch","validationCode":"#!/bin/sh\nQR_DIR=$(dirname \"$OUT_QR_PATH\")\n[ -d \"$QR_DIR\" ] || mkdir -p \"$QR_DIR\"\n[ -w \"$QR_DIR\" ] || { echo \"cannot write $QR_DIR\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"err = writeOutput(*cf.outQRPath, b, 0600, out)\nif err != nil {\n    return fmt.Errorf(\"error while writing out-qr: %s\", err)\n}","preventionTips":["mkdir -p the QR output directory first.","Ensure the QR path is a file path.","Drop -out-qr when the QR image is unnecessary."],"tags":["filesystem","qrcode","cli"],"backgroundTag":"file-write-permission-denied","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"}