{"record":{"id":"285773c88a9994c5","repo":"pion/webrtc","slug":"bad-payload-signature","errorCode":null,"errorMessage":"bad payload signature","messagePattern":"bad payload signature","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/media/oggreader/oggreader.go","lineNumber":29,"sourceCode":"\t\"io\"\n\t\"strings\"\n)\n\nconst (\n\tpageHeaderTypeBeginningOfStream = 0x02\n\tpageHeaderSignature             = \"OggS\"\n\n\tidPageBasePayloadLength = 19\n\tpageHeaderLen           = 27\n)\n\nvar (\n\terrNilStream                       = errors.New(\"stream is nil\")\n\terrBadIDPageSignature              = errors.New(\"bad header signature\")\n\terrBadOpusTagsSignature            = errors.New(\"bad opus tags signature\")\n\terrBadIDPageType                   = errors.New(\"wrong header, expected beginning of stream\")\n\terrBadIDPageLength                 = errors.New(\"payload for id page must be 19 bytes\")\n\terrBadIDPagePayloadSignature       = errors.New(\"bad payload signature\")\n\terrShortPageHeader                 = errors.New(\"not enough data for payload header\")\n\terrChecksumMismatch                = errors.New(\"expected and actual checksum do not match\")\n\terrUnsupportedChannelMappingFamily = errors.New(\"unsupported channel mapping family\")\n)\n\n// OggReader is used to read Ogg files and return page payloads.\ntype OggReader struct {\n\tstream               io.Reader\n\tbytesReadSuccesfully int64\n\tchecksumTable        *[256]uint32\n\tdoChecksum           bool\n}\n\n// OggHeader contains Opus codec metadata parsed from an Opus ID page.\n// This header is extracted from an Ogg page payload that starts with the OpusHead\n// signature (the first page of an Opus stream in an Ogg container).\n//\n// Use OggPageHeader.OpusPacketType() to classify a page payload as OpusHead,","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/pion/webrtc/blob/8c25dc09fa9e7c09aac4309ead88093d760432b0/pkg/media/oggreader/oggreader.go#L11-L47","documentation":"errBadIDPagePayloadSignature is returned when the ID page payload does not start with the 'OpusHead' magic signature (HeaderOpusID). The error is wrapped with the actual signature found, e.g. \"bad payload signature: expected OpusHead, got ....\" This indicates the stream is not an Opus stream despite passing the page-type checks.","triggerScenarios":"validateOpusPageHeader (oggreader.go:217) reading an ID page whose payload signature differs from OpusHead; also asserted in oggreader_test.go:182 with a corrupted signature.","commonSituations":"Pointing the Opus reader at a Vorbis/Speex/other Ogg stream, byte corruption in transit, or writing a wrong magic value in a synthetic stream.","solutions":["Verify the input is an Opus stream (payload begins with the 8 bytes 'OpusHead')","Use the correct reader for other codecs (e.g. a Vorbis reader)","Check for corruption or off-by-N offsets when slicing the payload"],"exampleFix":"// before: feeding a vorbis ogg file to the opus reader\nr, err := oggreader.NewWith(vorbisFile)\n// after\nif !bytes.HasPrefix(payload, []byte(\"OpusHead\")) {\n    return errors.New(\"not an opus stream\")\n}\nr, err := oggreader.NewWith(opusFile)","handlingStrategy":"validation","validationCode":"if !bytes.HasPrefix(payload, []byte(\"OpusHead\")) {\n    return fmt.Errorf(\"expected OpusHead, got %q\", payload[:min(8, len(payload))])\n}","typeGuard":"func isOpusHead(payload []byte) bool {\n    return bytes.HasPrefix(payload, []byte(\"OpusHead\"))\n}","tryCatchPattern":"_, hdr, err := oggreader.NewWith(f)\nif errors.Is(err, oggreader.ErrBadIDPagePayloadSignature) {\n    // input is not an Opus stream; select another decoder\n}","preventionTips":["Confirm codec (probe with ffprobe) before choosing the Ogg reader","Do not hand-edit ID page bytes","Route Vorbis/Speex streams to dedicated readers"],"tags":["ogg","opus","signature","stream-format"],"backgroundTag":"ogg-invalid-stream-header","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"}