You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WritePacket does not properly wrap errors, breaking errors.Is detection (should use %w not %v) #1213
In writer.go, the WritePacket function uses %v when returning wrapped errors. This prevents errors.Is and errors.As from working correctly on underlying system errors (e.g. syscall.ENOSPC when the disk is full).
From writer.go if err := w.writePacketHeader(ci); err != nil { return fmt.Errorf("error writing packet header: %v", err) }
This formats the error as a string but does not wrap it. As a result, error checks like this fail: if errors.Is(err, syscall.ENOSPC) { // never triggered }
Even though the underlying error is ENOSPC, it gets lost because %v does not preserve the error.
Why This Matters
Applications relying on gopacket cannot reliably detect and handle system-level write failures (like disk full, permissions, etc.), because the root error is lost. This makes robust error handling (like throttled logging or retries) impossible.
Proposed Fix
Change all %v error wrapping in return paths to %w where propagation is intended, e.g.:
Activity
fix: use %w for error wrapping in WritePacket
pcapgo: use %w instead of %v when wrapping errors in WritePacket
alliasgher commentedon Apr 14, 2026
Opened #1226 for this.