{"record":{"id":"5009775f4e895d7e","repo":"pion/webrtc","slug":"w-s-is-too-long","errorCode":null,"errorMessage":"%w: %s is too long","messagePattern":"%w: (.+?) is too long","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/media/oggwriter/oggwriter.go","lineNumber":825,"sourceCode":"\tif !isValidCommentName(comment.Comment) {\n\t\treturn fmt.Errorf(\"%w: invalid user comment name\", errInvalidOpusTags)\n\t}\n\tif err := validateOpusTagString(\"user comment value\", comment.Value); err != nil {\n\t\treturn err\n\t}\n\tif uint64(len(comment.Comment))+1+uint64(len(comment.Value)) > maxUint32Length {\n\t\treturn fmt.Errorf(\"%w: user comment is too long\", errInvalidOpusTags)\n\t}\n\n\treturn nil\n}\n\nfunc validateOpusTagString(field, value string) error {\n\tif !utf8.ValidString(value) {\n\t\treturn fmt.Errorf(\"%w: %s is not valid UTF-8\", errInvalidOpusTags, field)\n\t}\n\tif uint64(len(value)) > maxUint32Length {\n\t\treturn fmt.Errorf(\"%w: %s is too long\", errInvalidOpusTags, field)\n\t}\n\n\treturn nil\n}\n\nfunc isValidCommentName(comment string) bool {\n\tif comment == \"\" {\n\t\treturn false\n\t}\n\tfor i := 0; i < len(comment); i++ {\n\t\tb := comment[i]\n\t\tif b < 0x20 || b > 0x7d || b == '=' {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}","sourceCodeStart":807,"sourceCodeEnd":843,"githubUrl":"https://github.com/pion/webrtc/blob/8c25dc09fa9e7c09aac4309ead88093d760432b0/pkg/media/oggwriter/oggwriter.go#L807-L843","documentation":"validateOpusTagString rejects a string field (vendor or user comment value) whose byte length exceeds maxUint32Length (0xFFFFFFFF), because each OpusTags field is serialized with a 32-bit length prefix that cannot encode larger sizes. The error is wrapped by errInvalidOpusTags and the %s placeholder names the offending field (e.g. \"vendor\", \"user comment value\").","triggerScenarios":"Calling OpusTags validation with opusTags.Vendor or a UserComment.Value whose len() in bytes is greater than 4294967295. Note this check is per-string; a single comment's combined name+value limit is checked separately in validateUserComment (error 60).","commonSituations":"Embedding gigantic payloads (multi-GB base64 blobs, dumped file contents) as vendor strings or comment values; runaway string concatenation bugs; fuzz/boundary tests generating extreme inputs.","solutions":["Reduce the field's byte length to <= 4294967295 (in practice, keep metadata small — a few KiB is normal).","Move large binary data out of OpusTags into a separate stream or file and reference it by path/URL in the comment.","Add an upstream length check (utf8.ValidString + len bound) before building the OpusTags struct to fail with a clearer app-level message.","Use errors.Is(err, errInvalidOpusTags) to detect this family; the message identifies which field is oversized."],"exampleFix":"// before\ntags := oggwriter.OpusTags{Vendor: strings.Repeat(\"x\", 5<<30)} // 5 GiB vendor string\n// after\nconst maxVendorLen = 1 << 20\nif len(vendor) > maxVendorLen {\n  vendor = vendor[:maxVendorLen]\n}\ntags := oggwriter.OpusTags{Vendor: vendor}","handlingStrategy":"validation","validationCode":"func validateFieldLen(field, s string) error {\n\tif uint64(len(s)) > math.MaxUint32 {\n\t\treturn fmt.Errorf(\"%s too long: %d bytes\", field, len(s))\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := writer.WriteOpusTags(tags); err != nil {\n\tif errors.Is(err, oggwriter.ErrInvalidOpusTags) && strings.Contains(err.Error(), \"is too long\") {\n\t\t// truncate or relocate the oversized field, then retry\n\t}\n\treturn err\n}","preventionTips":["Enforce a sane metadata size budget (e.g. 64 KiB per field) at the application boundary.","Check len() bounds on vendor and comment values before constructing OpusTags.","Guard against accidental string amplification (repeated concatenation in loops).","Keep large payloads out of metadata entirely; store them as separate streams or files."],"tags":["go","ogg","opus","metadata","validation","size-limit"],"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"}