{"record":{"id":"95adeddd8fa26da2","repo":"pion/webrtc","slug":"invalid-nil-packet","errorCode":null,"errorMessage":"invalid nil packet","messagePattern":"invalid nil packet","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/media/ivfwriter/ivfwriter.go","lineNumber":20,"sourceCode":"func (i *IVFWriter) WriteRTP(packet *rtp.Packet) error {\n\tif i.ioWriter == nil {\n\t\treturn errFileNotOpened\n\t} else if len(packet.Payload) == 0 {\n\t\treturn nil\n\t}\n\n\tif i.count == 0 {\n\t\ti.firstFrameTimestamp = packet.Timestamp\n\t}\n\n\tvar timestamp uint64\n\tif i.directPTS {\n\t\t// Direct PTS mode: use RTP timestamp directly (no millisecond conversion).\n\t\ttimestamp = uint64(packet.Timestamp - i.firstFrameTimestamp)\n\t} else {\n\t\t// Existing behavior: convert to milliseconds first.\n\t\ttimestamp = 1000 * uint64(packet.Timestamp-i.firstFrameTimestamp) / i.clockRate\n\t}\n\n\tswitch i.codec {\n\tcase codecVP8:\n\t\treturn i.writeVP8(packet, timestamp)\n\tcase codecVP9:\n\t\treturn i.writeVP9(packet, timestamp)\n\tcase codecAV1:\n\t\treturn i.writeAV1(packet, timestamp)\n\tdefault:\n\t\treturn errCodecUnset\n\t}\n}","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/pion/webrtc/blob/8c25dc09fa9e7c09aac4309ead88093d760432b0/pkg/media/ivfwriter/ivfwriter.go#L2-L38","documentation":"WriteRTP rejects a nil *rtp.Packet argument (or a packet with nil inner payload structures); it is a generic nil-guard so the writer never dereferences a nil packet while depacketizing VP8/VP9/AV1 payloads. Note an empty (non-nil) packet payload is silently ignored, not an error.","triggerScenarios":"Thrown at pkg/media/ivfwriter/ivfwriter.go:20 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check packet != nil before calling WriteRTP","Skip nil packets in the RTP receive loop instead of forwarding them to the writer","If using SampleBuilder, ensure it never emits nil packets"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c25dc09fa9e7c09aac4309ead88093d760432b0","analyzedAt":"2026-09-03T21:56:56.182Z","contentChangedAt":"2026-09-03T21:56:56.182Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}