{"record":{"id":"4aba598bf960723f","repo":"pion/webrtc","slug":"incomplete-frame-data","errorCode":null,"errorMessage":"incomplete frame data","messagePattern":"incomplete frame data","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/media/ivfreader/ivfreader.go","lineNumber":23,"sourceCode":"package ivfreader\n\nimport (\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n)\n\nconst (\n\tivfFileHeaderSignature = \"DKIF\"\n\tivfFileHeaderSize      = 32\n\tivfFrameHeaderSize     = 12\n)\n\nvar (\n\terrNilStream             = errors.New(\"stream is nil\")\n\terrIncompleteFrameHeader = errors.New(\"incomplete frame header\")\n\terrIncompleteFrameData   = errors.New(\"incomplete frame data\")\n\terrIncompleteFileHeader  = errors.New(\"incomplete file header\")\n\terrSignatureMismatch     = errors.New(\"IVF signature mismatch\")\n\terrUnknownIVFVersion     = errors.New(\"IVF version unknown, parser may not parse correctly\")\n\terrInvalidMediaTimebase  = errors.New(\"invalid media timebase\")\n)\n\n// IVFFileHeader 32-byte header for IVF files\n// https://wiki.multimedia.cx/index.php/IVF\ntype IVFFileHeader struct {\n\tsignature           string // 0-3\n\tversion             uint16 // 4-5\n\theaderSize          uint16 // 6-7\n\tFourCC              string // 8-11\n\tWidth               uint16 // 12-13\n\tHeight              uint16 // 14-15\n\tTimebaseDenominator uint32 // 16-19\n\tTimebaseNumerator   uint32 // 20-23\n\tNumFrames           uint32 // 24-27","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/pion/webrtc/blob/8c25dc09fa9e7c09aac4309ead88093d760432b0/pkg/media/ivfreader/ivfreader.go#L5-L41","documentation":"Returned by IVFReader.ParseNextFrame when the frame header was read successfully but io.ReadFull hit io.ErrUnexpectedEOF while reading the frame's payload bytes, meaning the stream ended before the declared frame size was fully available.","triggerScenarios":"ParseNextFrame where the payload (per the 12-byte frame header's size field) extends beyond the end of the stream.","commonSituations":"Truncated or partially downloaded IVF files, corrupt frame-size fields, reading a file mid-write, piping a stream that closed early.","solutions":["Verify and re-acquire the source IVF file (complete download, valid size).","Catch this error specifically to treat truncation as a graceful end-of-stream if partial data is acceptable.","Sanitize frame-size fields if the file comes from an untrusted producer."],"exampleFix":"// before\npayload, _, err := reader.ParseNextFrame()\nif err != nil { return err }\n// after\npayload, _, err := reader.ParseNextFrame()\nif err == ivfreader.ErrIncompleteFrameData {\n    log.Warn(\"frame payload truncated at end of file\")\n    return nil\n} else if err != nil {\n    return err\n}","handlingStrategy":"try-catch","validationCode":"if fi.Size() < int64(32+12) {\n    return errors.New(\"file too small to contain frame data\")\n}","typeGuard":null,"tryCatchPattern":"frame, hdr, err := reader.ParseNextFrame()\nif err == ivfreader.ErrIncompleteFrameData {\n    log.Warn(\"frame payload truncated at end of IVF stream\")\n    return nil\n} else if err != nil {\n    return err\n}","preventionTips":["Re-download or re-capture truncated IVF files; check total size against expected duration/bitrate.","Validate frame-size sanity (e.g. size <= remaining file bytes) when consuming untrusted files.","Close producers before consuming so the stream isn't cut mid-frame."],"tags":["go","media","ivf","truncated-data"],"backgroundTag":"truncated-input-stream","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"}