pion/webrtc · error
%w: %s is too long
Error message
%w: %s is too long
What it means
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").
Source
Thrown at pkg/media/oggwriter/oggwriter.go:825
if !isValidCommentName(comment.Comment) {
return fmt.Errorf("%w: invalid user comment name", errInvalidOpusTags)
}
if err := validateOpusTagString("user comment value", comment.Value); err != nil {
return err
}
if uint64(len(comment.Comment))+1+uint64(len(comment.Value)) > maxUint32Length {
return fmt.Errorf("%w: user comment is too long", errInvalidOpusTags)
}
return nil
}
func validateOpusTagString(field, value string) error {
if !utf8.ValidString(value) {
return fmt.Errorf("%w: %s is not valid UTF-8", errInvalidOpusTags, field)
}
if uint64(len(value)) > maxUint32Length {
return fmt.Errorf("%w: %s is too long", errInvalidOpusTags, field)
}
return nil
}
func isValidCommentName(comment string) bool {
if comment == "" {
return false
}
for i := 0; i < len(comment); i++ {
b := comment[i]
if b < 0x20 || b > 0x7d || b == '=' {
return false
}
}
return true
}View on GitHub (pinned to 8c25dc09fa)
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.
Example fix
// before
tags := oggwriter.OpusTags{Vendor: strings.Repeat("x", 5<<30)} // 5 GiB vendor string
// after
const maxVendorLen = 1 << 20
if len(vendor) > maxVendorLen {
vendor = vendor[:maxVendorLen]
}
tags := oggwriter.OpusTags{Vendor: vendor} Defensive patterns
Strategy: validation
Validate before calling
func validateFieldLen(field, s string) error {
if uint64(len(s)) > math.MaxUint32 {
return fmt.Errorf("%s too long: %d bytes", field, len(s))
}
return nil
} Try / catch
if err := writer.WriteOpusTags(tags); err != nil {
if errors.Is(err, oggwriter.ErrInvalidOpusTags) && strings.Contains(err.Error(), "is too long") {
// truncate or relocate the oversized field, then retry
}
return err
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- %w: user comment is too long
- %w: invalid comment %d
- %w: stream count must be one
- %w: coupled count exceeds stream count
- %w: channel map entry is out of range
AI-assisted analysis of pion/webrtc@8c25dc09fa (2026-09-03).
Data as JSON: /api/errors/5009775f4e895d7e.
Report an issue: GitHub.