You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Human Input v2 IM link form tokens can be split by Markdown emphasis #46776
I have read the Contributing Guide and Language Policy.
This is a bug report, not a question.
I searched existing issues, including closed ones.
I am using English to submit this report.
I have not modified the template.
Dify version
main at 2b10f864 (2026-11-19)
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
Configure a Human Input v2 node whose form contains a file input, plus an IM channel on Slack, Microsoft Teams, or Feishu/Lark.
Deliver the form to an IM recipient. The card codecs reject file inputs, so _deliver_im takes the IMMessageType.LINK branch in api/services/human_input_v2/delivery_service.py and builds the form URL with secrets.token_urlsafe(32).
A base64url token can contain _ and -. When the token starts with _ and contains another _, the provider's Markdown parser treats the pair as emphasis and splits the URL.
A probe with this repo's Python-Markdown 3.10.2 shows 1,543 of 200,000 token_urlsafe(32) values start with _ and contain another _ (0.77%). With a forced _g_-... token, the body renders as https://app.example.com/form-v2/<em>g</em>-oa..., so the link no longer opens the form.
Expected Behavior
The generated form URL stays byte-literal in the Markdown message, the invariant stated by generate_form_link_token().
Actual Behavior
Roughly 0.77% of IM link deliveries get a URL that the Markdown parser splits, so the recipient cannot open the approval form.
Additional context
Merged #46722 introduced generate_form_link_token() with the docstring "Generate a 256-bit token that stays literal in a Markdown message", and switched the email delivery branch and the test-form service to it. The runtime IM LINK branch was missed. Slack, Teams, and Feishu send_text are Markdown transports, and file-input forms always take the LINK branch because the card codecs reject file inputs.
The fix is one line: use generate_form_link_token() in _deliver_im as well. The token is opaque to the card branch too. I have a regression test that renders the captured IM body with EmailDeliveryConfig.render_markdown_body and checks the URL survives; it fails on main and passes with the change. I will link the PR.
Activity