{"record":{"id":"71b5a60121d51b45","repo":"pion/webrtc","slug":"w-invalid-comment-d","errorCode":null,"errorMessage":"%w: invalid comment %d","messagePattern":"%w: invalid comment (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/media/oggreader/oggreader.go","lineNumber":482,"sourceCode":"func parseSingleUserComment(payload []byte, pos, u32Size, index int) (UserComment, int, error) {\n\tif pos+u32Size > len(payload) {\n\t\treturn UserComment{}, 0, fmt.Errorf(\"%w: payload too short for comment len %d\", errBadOpusTagsSignature, index)\n\t}\n\n\tcommentLen32 := binary.LittleEndian.Uint32(payload[pos : pos+u32Size])\n\tpos += u32Size\n\n\tcommentLen := int(commentLen32)\n\tif commentLen < 0 || pos+commentLen > len(payload) {\n\t\treturn UserComment{}, 0, fmt.Errorf(\"%w: payload too short for comment %d\", errBadOpusTagsSignature, index)\n\t}\n\n\tcomment := string(payload[pos : pos+commentLen])\n\tpos += commentLen\n\n\tparts := strings.SplitN(comment, \"=\", 2)\n\tif len(parts) != 2 {\n\t\treturn UserComment{}, 0, fmt.Errorf(\"%w: invalid comment %d\", errBadOpusTagsSignature, index)\n\t}\n\n\treturn UserComment{\n\t\tComment: parts[0],\n\t\tValue:   parts[1],\n\t}, pos, nil\n}\n","sourceCodeStart":464,"sourceCodeEnd":490,"githubUrl":"https://github.com/pion/webrtc/blob/8c25dc09fa9e7c09aac4309ead88093d760432b0/pkg/media/oggreader/oggreader.go#L464-L490","documentation":"Returned by parseSingleUserComment when a comment string, though fully present in the payload, contains no '=' separator. Per the Opus spec, every user comment must be a 'NAME=value' pair, so a comment without '=' is structurally invalid.","triggerScenarios":"Parsing an OpusTags payload where comment N is a non-empty string lacking an '=' character (e.g. 'TITLE' instead of 'TITLE=Song'), so strings.SplitN(comment, \"=\", 2) yields only one part.","commonSituations":"Metadata written by broken or non-conforming taggers, hand-edited OpusTags blocks, tools that append bare strings as comments, or comments that were truncated exactly at (or before) the '=' sign by a prior corruption.","solutions":["Fix the metadata with a conforming tag editor (e.g. opustags, ffmpeg -metadata) ensuring every comment is NAME=value.","Inspect the raw comments in the file to find the offending entry and correct or remove it.","Use errors.Is(err, errBadOpusTagsSignature) to detect this and either reject the file or strip invalid comments.","If you generate OpusTags yourself, always validate each comment contains '=' before serializing."],"exampleFix":"// before: writing a bare comment\ncomments := []string{\"TITLE Song\"}\n// after: ensure KEY=value form\ncomments := []string{\"TITLE=Song\"}\nfor _, c := range comments { if !strings.Contains(c, \"=\") { return errors.New(\"invalid comment\") } }","handlingStrategy":"try-catch","validationCode":"func allCommentsAreKeyValue(rawComments []string) bool {\n    for _, c := range rawComments {\n        if !strings.Contains(c, \"=\") { return false }\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":"tags, err := ParseOpusTags(payload)\nif err != nil {\n    if errors.Is(err, errBadOpusTagsSignature) && strings.Contains(err.Error(), \"invalid comment\") {\n        return nil, fmt.Errorf(\"non-conforming metadata (comment missing '='): %w\", err)\n    }\n    return nil, err\n}","preventionTips":["Write metadata only with spec-conforming tools; every comment must be NAME=value.","Validate comments contain '=' before serializing OpusTags yourself.","When reading third-party files, run a pre-scan with opustags or ffprobe to catch bad taggers.","Keep the '=' out of neither side: note the value side may contain '=' — only split on the first occurrence."],"tags":["go","ogg","opus","metadata","spec-violation"],"backgroundTag":"invalid-opus-tags-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"}