{"record":{"id":"f3b8d0330fda028a","repo":"netbirdio/netbird","slug":"s","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/capture.go","lineNumber":193,"sourceCode":"\t\tfi, statErr := os.Stat(tmpPath)\n\t\tif statErr != nil || fi.Size() == 0 {\n\t\t\tif rmErr := os.Remove(tmpPath); rmErr != nil && !os.IsNotExist(rmErr) {\n\t\t\t\tmerr = multierror.Append(merr, fmt.Errorf(\"remove empty output file: %w\", rmErr))\n\t\t\t}\n\t\t\treturn nberrors.FormatErrorOrNil(merr)\n\t\t}\n\t\tif err := os.Rename(tmpPath, outPath); err != nil {\n\t\t\tmerr = multierror.Append(merr, fmt.Errorf(\"rename output file: %w\", err))\n\t\t\treturn nberrors.FormatErrorOrNil(merr)\n\t\t}\n\t\tcmd.PrintErrf(\"Wrote %s\\n\", outPath)\n\t\treturn nberrors.FormatErrorOrNil(merr)\n\t}, nil\n}\n\nfunc handleCaptureError(err error) error {\n\tif s, ok := status.FromError(err); ok {\n\t\treturn fmt.Errorf(\"%s\", s.Message())\n\t}\n\treturn err\n}\n","sourceCodeStart":175,"sourceCodeEnd":197,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/capture.go#L175-L197","documentation":"handleCaptureError converts a gRPC status error coming from the StartCapture RPC or the packet stream into a plain message string, discarding the gRPC envelope (code, rpc name). This is the shape you see when the daemon itself refuses or aborts the capture: capture not enabled at service install time, the capture device unavailable (kernel WireGuard mode, interface not connected), or the stream failing mid-capture. The concrete reason is whatever message the daemon attached to the status.","triggerScenarios":"Running netbird debug capture without --enable-capture set at install/reconfigure time (daemon rejects); agent in kernel-mode WireGuard where no userspace capture hook exists; peer not connected so the capture device is absent; daemon restarting/context canceled mid-stream surfacing as 'context canceled' or 'rpc error' text.","commonSituations":"Fresh install forgetting the enable flag; switching the agent between userspace and kernel modes; capture started while netbird is still connecting; version skew between CLI and daemon where StartCapture is unsupported.","solutions":["For the 'not enabled' refusal: reconfigure the service with capture enabled (netbird up --enable-capture or reconfigure-time flag per your install) and retry","Ensure the agent is connected (netbird status) and running in a capture-capable mode (userspace/netstack), then retry","Check daemon logs (journalctl -u netbird or the log file) at the timestamp — the same status message appears with more context there","Restart the daemon if the stream broke due to a daemon restart, then rerun the capture"],"exampleFix":"# before: capture requested on an install without it\nnetbird debug capture\n# -> capture is not enabled ...\n\n# after: enable at (re)configure time, then capture\nnetbird up --enable-capture\nnetbird debug capture -d 30s -o /tmp/c.pcap","handlingStrategy":"try-catch","validationCode":"// Before capturing, confirm the feature is on and the peer is connected:\nout, _ := exec.Command(\"netbird\", \"status\").Output() // check 'Connected' and capture support\n// At install time: netbird up --enable-capture","typeGuard":"// Distinguish daemon refusals from transport failures:\nfunc isCaptureDisabled(err error) bool {\n    s, ok := status.FromError(err)\n    return ok && strings.Contains(s.Message(), \"not enabled\")\n}","tryCatchPattern":"// Map known daemon refusals to actionable guidance:\nerr := runCapture()\nif s, ok := status.FromError(err); ok {\n    switch {\n    case strings.Contains(s.Message(), \"not enabled\"):\n        hint(\"re-run netbird up --enable-capture\")\n    case strings.Contains(s.Message(), \"unavailable\"):\n        hint(\"check kernel/userspace mode and connection\")\n    default:\n        hint(\"inspect daemon logs: \" + s.Message())\n    }\n}","preventionTips":["Enable --enable-capture at install/reconfigure time; it cannot be toggled per-command","Confirm netbird status shows a connected peer in a capture-capable mode before capturing","On daemon restarts mid-stream, rerun the capture rather than relying on the dead stream"],"tags":["capture","grpc","daemon","cli","status"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}