From d19f234d7b68db0afcd53075115c4959f671cdc6 Mon Sep 17 00:00:00 2001 From: Next Alone <12210746+NextAlone@users.noreply.github.com> Date: Sun, 19 Apr 2026 22:54:11 +0800 Subject: [PATCH] ci: truncate commit message before telegram upload sendDocument caption limit is 1024 chars. After backtick-stripping, long commit bodies still bust the limit and uploadCI.py fails with 400 Bad Request. Do both the strip and an 800-char cap in one Python step so the release notification survives verbose commits. --- .github/workflows/ci.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa86b9f78..b3744c7f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -153,11 +153,22 @@ jobs: chmod +x telegram-bot-api-binary ./telegram-bot-api-binary --api-id=21724 --api-hash=3e0cb5efcd52300aec5994fdfc5bdc16 --local 2>&1 > /dev/null & curl https://raw.githubusercontent.com/PreviousAlone/ActionScript/main/uploadCI.py -o uploadCI.py - # Legacy Telegram Markdown (used by uploadCI.py) fails with - # "can't parse entities" when the commit body contains backticks — - # they clash with the ``` fence the template wraps the message in. - # Strip them (and any CR) before passing to the uploader. - sanitized=$(printf '%s' "$COMMIT_MESSAGE" | tr -d '`\r') + # Normalise COMMIT_MESSAGE for the Telegram uploader: + # 1. Strip backticks — legacy Markdown parse_mode trips on + # "can't parse entities" when the commit body contains them + # because they collide with the ``` fence in the template. + # 2. Cap length — sendDocument caption limit is 1024 chars; + # template + version adds ~120, so truncate the body to 800 + # to leave headroom and avoid HTTP 400. + sanitized=$(python3 <<'PY' + import os + s = os.environ["COMMIT_MESSAGE"].replace("`", "").replace("\r", "") + MAX = 800 + if len(s) > MAX: + s = s[:MAX].rstrip() + "\n…(truncated)" + print(s) + PY + ) COMMIT_MESSAGE="$sanitized" python uploadCI.py env: CHAT_ID: ${{ secrets.TELEGRAM_CHATID }}