{"record":{"id":"0d5632ee54bbed16","repo":"pion/webrtc","slug":"w-header-is-too-long","errorCode":null,"errorMessage":"%w: header is too long","messagePattern":"%w: header is too long","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/media/oggwriter/oggwriter.go","lineNumber":781,"sourceCode":"func validateOpusTagsWithMaxHeaderLen(opusTags OpusTags, maxHeaderLen uint64) error {\n\tif err := validateOpusTagString(\"vendor\", opusTags.Vendor); err != nil {\n\t\treturn err\n\t}\n\tif uint64(len(opusTags.UserComments)) > maxUint32Length {\n\t\treturn fmt.Errorf(\"%w: too many user comments\", errInvalidOpusTags)\n\t}\n\n\tif err := validateUserComments(opusTags.UserComments); err != nil {\n\t\treturn err\n\t}\n\n\treturn validateOpusTagsHeaderLen(opusTags, maxHeaderLen)\n}\n\nfunc validateOpusTagsHeaderLen(opusTags OpusTags, maxHeaderLen uint64) error {\n\theaderLen := uint64(len(commentPageSignature)) + 4 + uint64(len(opusTags.Vendor)) + 4\n\tif headerLen > maxHeaderLen {\n\t\treturn fmt.Errorf(\"%w: header is too long\", errInvalidOpusTags)\n\t}\n\n\tfor _, comment := range opusTags.UserComments {\n\t\tuserCommentLen := uint64(len(comment.Comment)) + 1 + uint64(len(comment.Value))\n\t\tcommentFieldLen := 4 + userCommentLen\n\t\tif commentFieldLen > maxHeaderLen-headerLen {\n\t\t\treturn fmt.Errorf(\"%w: header is too long\", errInvalidOpusTags)\n\t\t}\n\t\theaderLen += commentFieldLen\n\t}\n\n\treturn nil\n}\n\nfunc validateUserComments(comments []UserComment) error {\n\tfor _, comment := range comments {\n\t\tif err := validateUserComment(comment); err != nil {\n\t\t\treturn err","sourceCodeStart":763,"sourceCodeEnd":799,"githubUrl":"https://github.com/pion/webrtc/blob/8c25dc09fa9e7c09aac4309ead88093d760432b0/pkg/media/oggwriter/oggwriter.go#L763-L799","documentation":"The Opus comment header (signature 'OpusTags' + vendor length + vendor string + comment count) must fit within the configured maximum header length, typically one Ogg page. validateOpusTagsHeaderLen computes the base header length and returns this wrapped errInvalidOpusTags when the vendor string alone makes it exceed maxHeaderLen.","triggerScenarios":"Setting a very long Vendor string on OpusTags (or via the vendor-setting API) so that len('OpusTags')+4+vendor+4 exceeds maxHeaderLen before any comments are considered.","commonSituations":"Using a long marketing/version string as the vendor tag; libraries that copy vendor strings from decoded input files into new recordings; a small maxHeaderLen (single Ogg page ≈ 65KB) combined with verbose vendor text.","solutions":["Shorten the vendor string to fit (keep it well under ~65000 bytes).","Raise the maxHeaderLen parameter if your pipeline allows larger headers.","Drop or truncate the vendor to the default (defaultOpusTags uses a short defaultVendor).","Precompute headerLen = 8+4+len(vendor)+4 and assert it <= maxHeaderLen before calling the writer."],"exampleFix":"// before\ntags.Vendor = strings.Repeat(\"x\", 100000)\n// after\ntags.Vendor = \"myapp v1.2\" // short vendor fits in one page","handlingStrategy":"validation","validationCode":"headerLen := uint64(8 + 4 + len(tags.Vendor) + 4)\nif headerLen > maxHeaderLen { return errors.New(\"vendor string too long for header\") }","typeGuard":null,"tryCatchPattern":"if err := writer.SetOpusTags(tags); err != nil {\n    if errors.Is(err, errInvalidOpusTags) && strings.Contains(err.Error(), \"header is too long\") {\n        tags.Vendor = shortVendor; /* retry */\n    }\n    return err\n}","preventionTips":["Keep vendor strings short (< a few hundred bytes)","Precompute 8+4+len(vendor)+4 against your page-size budget","Don't copy long vendor strings from decoded input files","Use the library's default vendor when in doubt"],"tags":["go","opus","opus-tags","metadata","validation"],"backgroundTag":"invalid-opus-tags","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"}