telegram-action icon indicating copy to clipboard operation
telegram-action copied to clipboard

Upgrading from v0.1.1 to v1.0.0 brings some breaking change(s) with tg markdown syntax parsing

Open rc5hack opened this issue 1 year ago • 2 comments

I used to include telegram-action into my Github workflows in that manner:

uses: appleboy/telegram-action@master

Some weeks ago I noticed that my Github actions workflows stopped to send notifications to telegram.

While investigating, I found that telegram-action was updated some time ago.

By replacing uses: appleboy/telegram-action@master with uses: appleboy/[email protected] and uses: appleboy/[email protected] I discovered, that my workflow works fine on v0.1.1 and don't work with v1.0.0.

With v1.0.0 I get an error

Bad Request: can't parse entities: Can't find end of the entity starting at byte offset X

Full log:

Run appleboy/[email protected]
/usr/bin/docker run --name abf7cbeade0e989d2e44e0a7f8777307a3225d_abb92c --label abf7cb --workdir /github/workspace --rm 
-e "AUTODEPLOY_STATUS" 
-e "AUTODEPLOY_STATUS_EMODJI" 
-e "AUTODEPLOY_MESSAGE" 
-e "LOGSARCHIVE_ZIP" 
-e "INPUT_TO" 
-e "INPUT_TOKEN" 
-e "INPUT_DISABLE_WEB_PAGE_PREVIEW" 
-e "INPUT_DOCUMENT" 
-e "INPUT_FORMAT" 
-e "INPUT_MESSAGE" 
-e "INPUT_MESSAGE_FILE" 
-e "INPUT_SOCKS5" 
-e "INPUT_PHOTO" 
-e "INPUT_STICKER" 
-e "INPUT_AUDIO" 
-e "INPUT_VOICE" 
-e "INPUT_LOCATION" 
-e "INPUT_VENUE" 
-e "INPUT_VIDEO" 
-e "INPUT_DEBUG" 
-e "INPUT_DISABLE_NOTIFICATION" 
-e "HOME" 
-e "GITHUB_JOB" 
-e "GITHUB_REF" 
-e "GITHUB_SHA" 
-e "GITHUB_REPOSITORY" 
-e "GITHUB_REPOSITORY_OWNER" 
-e "GITHUB_REPOSITORY_OWNER_ID" 
-e "GITHUB_RUN_ID" 
-e "GITHUB_RUN_NUMBER" 
-e "GITHUB_RETENTION_DAYS" 
-e "GITHUB_RUN_ATTEMPT" 
-e "GITHUB_REPOSITORY_ID" 
-e "GITHUB_ACTOR_ID" 
-e "GITHUB_ACTOR" 
-e "GITHUB_TRIGGERING_ACTOR" 
-e "GITHUB_WORKFLOW" 
-e "GITHUB_HEAD_REF" 
-e "GITHUB_BASE_REF" 
-e "GITHUB_EVENT_NAME" 
-e "GITHUB_SERVER_URL" 
-e "GITHUB_API_URL" 
-e "GITHUB_GRAPHQL_URL" 
-e "GITHUB_REF_NAME" 
-e "GITHUB_REF_PROTECTED" 
-e "GITHUB_REF_TYPE" 
-e "GITHUB_WORKFLOW_REF" 
-e "GITHUB_WORKFLOW_SHA" 
-e "GITHUB_WORKSPACE" 
-e "GITHUB_ACTION" 
-e "GITHUB_EVENT_PATH" 
-e "GITHUB_ACTION_REPOSITORY" 
-e "GITHUB_ACTION_REF" 
-e "GITHUB_PATH" 
-e "GITHUB_ENV" 
-e "GITHUB_STEP_SUMMARY" 
-e "GITHUB_STATE" 
-e "GITHUB_OUTPUT" 
-e "RUNNER_OS" 
-e "RUNNER_ARCH" 
-e "RUNNER_NAME" 
-e "RUNNER_ENVIRONMENT" 
-e "RUNNER_TOOL_CACHE" 
-e "RUNNER_TEMP" 
-e "RUNNER_WORKSPACE" 
-e "ACTIONS_RUNTIME_URL" 
-e "ACTIONS_RUNTIME_TOKEN" 
-e "ACTIONS_CACHE_URL" 
-e "ACTIONS_RESULTS_URL" 
-e GITHUB_ACTIONS=true 
-e CI=true 
-v "/var/run/docker.sock":"/var/run/docker.sock" 
-v "/opt/gh-actions-runner/_work/_temp/_github_home":"/github/home" 
-v "/opt/gh-actions-runner/_work/_temp/_github_workflow":"/github/workflow" 
-v "/opt/gh-actions-runner/_work/_temp/_runner_file_commands":"/github/file_commands" 
-v "/opt/gh-actions-runner/_work/MyRepoName/MyRepoName":"/github/workspace" 
abf7cb:eade0e989d2e44e0a7f8777307a3225d
2024/10/16 08:02:01 Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 646

With v0.1.1 everything is OK:

Run appleboy/[email protected]
/usr/bin/docker run --name abf7cb8e043a5cd9ae4b4aa2762e81f7f95610_483edf --label abf7cb --workdir /github/workspace --rm 
-e "AUTODEPLOY_STATUS" 
-e "AUTODEPLOY_STATUS_EMODJI" 
-e "AUTODEPLOY_MESSAGE" 
-e "LOGSARCHIVE_ZIP" 
-e "INPUT_TO" 
-e "INPUT_TOKEN" 
-e "INPUT_DISABLE_WEB_PAGE_PREVIEW" 
-e "INPUT_DOCUMENT" 
-e "INPUT_FORMAT" 
-e "INPUT_MESSAGE" 
-e "INPUT_MESSAGE_FILE" 
-e "INPUT_SOCKS5" 
-e "INPUT_PHOTO" 
-e "INPUT_STICKER" 
-e "INPUT_AUDIO" 
-e "INPUT_VOICE" 
-e "INPUT_LOCATION" 
-e "INPUT_VENUE" 
-e "INPUT_VIDEO" 
-e "INPUT_DEBUG" 
-e "INPUT_DISABLE_NOTIFICATION" 
-e "HOME" 
-e "GITHUB_JOB" 
-e "GITHUB_REF" 
-e "GITHUB_SHA" 
-e "GITHUB_REPOSITORY" 
-e "GITHUB_REPOSITORY_OWNER" 
-e "GITHUB_REPOSITORY_OWNER_ID" 
-e "GITHUB_RUN_ID" 
-e "GITHUB_RUN_NUMBER" 
-e "GITHUB_RETENTION_DAYS" 
-e "GITHUB_RUN_ATTEMPT" 
-e "GITHUB_REPOSITORY_ID" 
-e "GITHUB_ACTOR_ID" 
-e "GITHUB_ACTOR" 
-e "GITHUB_TRIGGERING_ACTOR" 
-e "GITHUB_WORKFLOW" 
-e "GITHUB_HEAD_REF" 
-e "GITHUB_BASE_REF" 
-e "GITHUB_EVENT_NAME" 
-e "GITHUB_SERVER_URL" 
-e "GITHUB_API_URL" 
-e "GITHUB_GRAPHQL_URL" 
-e "GITHUB_REF_NAME" 
-e "GITHUB_REF_PROTECTED" 
-e "GITHUB_REF_TYPE" 
-e "GITHUB_WORKFLOW_REF" 
-e "GITHUB_WORKFLOW_SHA" 
-e "GITHUB_WORKSPACE" 
-e "GITHUB_ACTION" 
-e "GITHUB_EVENT_PATH" 
-e "GITHUB_ACTION_REPOSITORY" 
-e "GITHUB_ACTION_REF" 
-e "GITHUB_PATH" 
-e "GITHUB_ENV" 
-e "GITHUB_STEP_SUMMARY" 
-e "GITHUB_STATE" 
-e "GITHUB_OUTPUT" 
-e "RUNNER_OS" 
-e "RUNNER_ARCH" 
-e "RUNNER_NAME" 
-e "RUNNER_ENVIRONMENT" 
-e "RUNNER_TOOL_CACHE" 
-e "RUNNER_TEMP" 
-e "RUNNER_WORKSPACE" 
-e "ACTIONS_RUNTIME_URL" 
-e "ACTIONS_RUNTIME_TOKEN" 
-e "ACTIONS_CACHE_URL" 
-e "ACTIONS_RESULTS_URL" 
-e GITHUB_ACTIONS=true 
-e CI=true 
-v "/var/run/docker.sock":"/var/run/docker.sock" 
-v "/opt/gh-actions-runner/_work/_temp/_github_home":"/github/home" 
-v "/opt/gh-actions-runner/_work/_temp/_github_workflow":"/github/workflow" 
-v "/opt/gh-actions-runner/_work/_temp/_runner_file_commands":"/github/file_commands" 
-v "/opt/gh-actions-runner/_work/MyRepoName/MyRepoName":"/github/workspace" 
abf7cb:8e043a5cd9ae4b4aa2762e81f7f95610

The messages I'm sending via workflow are exactly the same in both cases (only commit SHA differs).

Has anything changed in the way telegram-action parses tg markdown syntax in messages after upgrading from v0.1.1 to v1.0.0?

rc5hack avatar Oct 16 '24 09:10 rc5hack

After some experimentation, I was able to reproduce the issue with a minimal amount of code.

So this works fine (legacy version):

    - name: Send telegram notification v0.1.1
      id: notify_tg_v011
      if: ${{always()}}
      uses: appleboy/[email protected]
      with:
        to: ${{secrets.TELEGRAM_DEBUG_CHAT}}
        token: ${{secrets.TELEGRAM_DEBUG_TOKEN}}
        disable_web_page_preview: true
        format: markdown
        message: |
          some text with @tg_link

This fails (modern version):

    - name: Send telegram notification v1.0.0
      id: notify_tg_v100
      if: ${{always()}}
      uses: appleboy/[email protected]
      with:
        to: ${{secrets.TELEGRAM_DEBUG_CHAT}}
        token: ${{secrets.TELEGRAM_DEBUG_TOKEN}}
        disable_web_page_preview: true
        format: markdown
        message: |
          some text with @tg_link

Error message for this certain code sample:

2024/10/16 10:19:18 Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 18

rc5hack avatar Oct 16 '24 10:10 rc5hack

could be explicitly fixed by replacing all _ symbols with \_, like this:

    - name: Send telegram notification v1.0.0
      id: notify_tg_v100
      if: ${{always()}}
      uses: appleboy/[email protected]
      with:
        to: ${{secrets.TELEGRAM_DEBUG_CHAT}}
        token: ${{secrets.TELEGRAM_DEBUG_TOKEN}}
        disable_web_page_preview: true
        format: markdown
        message: |
          some text with @tg\_link

However, the issue of the behavior unexpectedly changing when upgrading from v0.1.1 to v1.0.0, remains relevant.

rc5hack avatar Oct 16 '24 10:10 rc5hack