Skip to content

fix(issues): strip invisible characters from add_issue_comment body#2786

Open
syf2211 wants to merge 2 commits into
github:mainfrom
syf2211:fix/2714-sanitize-issue-comment-body
Open

fix(issues): strip invisible characters from add_issue_comment body#2786
syf2211 wants to merge 2 commits into
github:mainfrom
syf2211:fix/2714-sanitize-issue-comment-body

Conversation

@syf2211

@syf2211 syf2211 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Strip invisible Unicode control characters (especially BiDi isolates) from add_issue_comment bodies before posting to GitHub.

Motivation

Fixes #2714. When MCP clients insert BiDi isolate characters between letters, GitHub can render them as visible middle dots and break @mentions such as @dependabot rebase. Filtering these characters before CreateComment preserves the intended plain text.

Changes

  • Apply sanitize.FilterInvisibleCharacters to comment bodies in AddIssueComment before calling the GitHub API
  • Return a clear error if the body becomes empty after filtering
  • Add regression tests for sanitized posting and all-invisible rejection

Tests

go test ./pkg/github/... -run TestAddIssueComment -count=1
go test ./pkg/github/... ./pkg/sanitize/... -count=1

All tests pass.

Notes

This change is scoped to add_issue_comment only. Other comment write tools could receive the same treatment in a follow-up if maintainers want consistency.

syf2211 added 2 commits June 27, 2026 14:07
Filter BiDi and other invisible Unicode control characters from issue
comment bodies before posting to GitHub. These characters can render as
visible separators and break @mentions such as @dependabot rebase.

Fixes github#2714
@syf2211 syf2211 requested a review from a team as a code owner June 27, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Asking Dependabot to Rebase via MCP leads to malformed text in comment

1 participant