Skip to content

ci(notifications): escape commit messages in Telegram notifications - #980

Merged
T3ST3ST3R0N merged 1 commit into
devfrom
fix/telegram-notify-escape
Oct 8, 2026
Merged

T3ST3ST3R0N merged 1 commit into
devfrom
fix/telegram-notify-escape

Conversation

@T3ST3ST3R0N

@T3ST3ST3R0N T3ST3ST3R0N commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The "Telegram Notification" workflow fails on most pushes to dev (16 failures against 44 successes since 2026-09-20), so those notifications are never sent. Example: https://github.com/PasarGuard/panel/actions/runs/37852031693 ends with curl: (22) The requested URL returned error: 400.

The step sends with parse_mode=HTML and escapes the branch, actor and PR title, but not the commit messages. Any commit message with <, > or & breaks Telegram's HTML parsing. That includes every Co-authored-by: Name <email> trailer that GitHub adds to squash merges, and the Signed-off-by: dependabot[bot] <[email protected]> trailer on Dependabot commits. The one recent push that succeeded (#907's squash commit) is the one without such a trailer.

Change

After the push and PR branches build the commit list, it is:

  • escaped with the existing html_escape helper;
  • trimmed so the whole message stays under Telegram's 4096-character limit. The cut never splits an HTML entity, and it ends with ....

Testing

I ran the step's bash script locally with a fake curl and checked the text it would send against Telegram's HTML rules (only <b>/<a href> tags, valid entities, length limit). Four cases: a push with an email trailer and &/</>, a plain push, a push with 10 very long commit messages, and a PR event with a Signed-off-by trailer.

  • Before: 3 of 4 fail (raw </> in the text); the plain push passes, which matches what happens on GitHub.
  • After: all 4 pass. The real message of 8420c2c2 now renders as Co-authored-by: etm &lt;etm@LAPTOP-62O1BVSJ&gt;, and the long case is trimmed to 3904 characters.
  • Topic ids (chat^topic) are still sent.

Summary by CodeRabbit

  • Bug Fixes
    • Notification messages now safely format commit text and stay within the 3,900-character limit, truncating long lists cleanly with an ellipsis. The commit list remains limited to 10 entries.

The notification step sends with parse_mode=HTML and escapes the branch,
actor and PR title, but not the commit messages. Any commit with <, > or &
(for example every "Co-authored-by: Name <email>" or "Signed-off-by" trailer)
makes Telegram answer 400, so the step fails and no notification is sent.

Escape the commit list the same way, and trim it so the message stays
under Telegram's 4096-character limit.
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b03614c2-3b68-4ea4-88f3-27431b2f269e
📥 Commits

Reviewing files that changed from the base of the PR and between 8420c2c and 159e5cb.

📒 Files selected for processing (1)
  • .github/workflows/github-notifications-bot.yml

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

The notification workflow now applies shared HTML escaping and a 3,900-character message limit to commit text after the push or pull-request branch builds its message.

Changes

Notification message length limit

Layer / File(s) Summary
Shared commit formatting
.github/workflows/github-notifications-bot.yml
The push branch no longer appends commits directly. Shared logic HTML-escapes the commit text, truncates it to the remaining message budget, removes a trailing partial HTML entity, and adds an ellipsis when truncation occurs.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 159e5

Commit notifications now escape markup characters and trim long commit lists before delivery. No actionable delivery failure is established, so the change is minimally risky to merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: escaping commit messages in Telegram notifications. It is concise and specific.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

I’m a rabbit with a message to send
I tuck escaped commits around the bend
Three thousand nine hundred marks set the pace
A neat little ellipsis saves some space
Then I hop away, with a tidy ending

Comment @coderabbitai help to get the list of available commands.

@T3ST3ST3R0N
T3ST3ST3R0N merged commit ff6e596 into dev Oct 8, 2026
6 checks passed
@T3ST3ST3R0N
T3ST3ST3R0N deleted the fix/telegram-notify-escape branch October 22, 2026 12:34
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 2, 2026
… to ff6e596

Every Port queue line in the panel and side-repository ledgers now says
`security: yes` or `security: no`. Security: c9b445a (passkey client rename),
eb50bfd, PasarGuard#938, PasarGuard#940, PasarGuard#942, the cryptography 50.0.2 security release, and the ten
commits of upstream's PasarGuard#979 permission-leak batch (user list scopes, API-key
permissions, HWID visibility, users.read, the Telegram inline search), which no
branch ports yet.

Checked with git ls-remote on 2026-10-09: upstream dev moved to ff6e596. The
PasarGuard#979 batch, the node RPC fixes (PasarGuard#977, PasarGuard#978), the core-deletion restart (PasarGuard#934),
dashboard fixes (PasarGuard#852, PasarGuard#907, PasarGuard#949, PasarGuard#952), performance changes (PasarGuard#945, PasarGuard#853, PasarGuard#855) and
the merged dependabot bumps (ruff, uvloop, fastapi) join the queue; the ruff and
uvloop conditional waivers ended when upstream merged them. Waived: PasarGuard#980 and its
branch commit (the Telegram notifier workflow the fork deleted) and the superseded
fastapi dependabot head b021d6f. The refs snapshot records the five new heads.
Fork core-kit main 90701408 now contains upstream d2ecb5bd, so that ledger is empty.
No side repository gained an upstream commit since 2026-10-07.
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.

1 participant