{"record":{"id":"081d54760d9bab68","repo":"pion/webrtc","slug":"invalid-opustags","errorCode":null,"errorMessage":"invalid OpusTags","messagePattern":"invalid OpusTags","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/media/oggwriter/oggwriter.go","lineNumber":58,"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}","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/pion/webrtc/blob/8c25dc09fa9e7c09aac4309ead88093d760432b0/pkg/media/oggwriter/oggwriter.go#L40-L76","documentation":"errInvalidOpusTags is a sentinel wrapped by fmt.Errorf in the OpusTags validation used when writing the Opus comment header page. It fires when the caller-supplied OpusTags structure cannot be serialized: more user comments than fit a uint32 count, or the resulting comment header exceeds the maximum allowed header length (vendor string plus each COMMENT entry is length-checked).","triggerScenarios":"Thrown at pkg/media/oggwriter/oggwriter.go:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the number of user comments so the count fits in uint32","Shorten the vendor string or comment values so the total header fits the maximum size","Drop optional comments before writing; keep only essential tags","Validate OpusTags with the same limits before constructing the writer input"],"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"}