{"record":{"id":"b46b663158ab8fa7","repo":"probelabs/goreplay","slug":"expected-d-snap-length-to-be-at-least-0","errorCode":null,"errorMessage":"expected %d snap length to be at least 0","messagePattern":"expected (.+?) snap length to be at least 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/capture/sock_linux.go","lineNumber":189,"sourceCode":"func (sock *SockRaw) Close() (err error) {\n\tsock.mu.Lock()\n\tdefer sock.mu.Unlock()\n\tif sock.fd != -1 {\n\t\tunix.Munmap(sock.buf)\n\t\tsock.buf = nil\n\t\terr = unix.Close(sock.fd)\n\t\tsock.fd = -1\n\t}\n\treturn\n}\n\n// SetSnapLen sets the maximum capture length to the given value.\n// for this to take effects on the kernel level SetBPFilter should be called too.\nfunc (sock *SockRaw) SetSnapLen(snap int) error {\n\tsock.mu.Lock()\n\tdefer sock.mu.Unlock()\n\tif snap < 0 {\n\t\treturn fmt.Errorf(\"expected %d snap length to be at least 0\", snap)\n\t}\n\tif snap > FRAMESIZE {\n\t\tsnap = FRAMESIZE\n\t}\n\tsock.snaplen = snap\n\treturn nil\n}\n\n// SetTimeout sets poll wait timeout for the socket.\n// negative value will block forever\nfunc (sock *SockRaw) SetTimeout(t time.Duration) error {\n\tsock.mu.Lock()\n\tdefer sock.mu.Unlock()\n\tsock.pollTimeout = uintptr(t)\n\treturn nil\n}\n\n// GetSnapLen returns the maximum capture length","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/probelabs/goreplay/blob/251e45abd242886bb64ff2b2dc98789556b56330/internal/capture/sock_linux.go#L171-L207","documentation":"SetSnapLen rejects a negative snaplen argument before touching the socket; snap length is a capture size bound and a negative value is invalid input (it is silently clamped to FRAMESIZE if too large, but negatives always fail).","triggerScenarios":"Thrown at internal/capture/sock_linux.go:189 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-negative snaplen >= 0","Check the config computation that produced the snap value","Clamp caller-side values before calling SetSnapLen"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"251e45abd242886bb64ff2b2dc98789556b56330","analyzedAt":"2026-09-02T16:44:11.369Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}