[fix] never send null template variables to Aliyun SMS - #4331
Open
orangeCatDeveloper wants to merge 1 commit into
Open
[fix] never send null template variables to Aliyun SMS#4331orangeCatDeveloper wants to merge 1 commit into
orangeCatDeveloper wants to merge 1 commit into
Conversation
orangeCatDeveloper
force-pushed
the
fix/4319-alibaba-sms-null-param
branch
from
August 17, 2026 17:27
e4e72ef to
b64a76d
Compare
The send-test-msg alert carries no instance label and no groupKey, so
the Alibaba client serialized {"instance":null,...} and Aliyun rejected
every test send with a template-variable error. Fall back to non-blank
text for all three variables, add the instance label to the shared test
alert, and fix the doc template examples to Aliyun's ${...} syntax.
orangeCatDeveloper
force-pushed
the
fix/4319-alibaba-sms-null-param
branch
from
August 18, 2026 06:23
b64a76d to
2628bf8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4319
Sending a test SMS through Alibaba Cloud always fails with Aliyun's "模板变量JSON格式错误 或 JSON变量属性与模板占位符不一致" error, regardless of configuration — and the docs make it worse by showing a template example in the wrong placeholder syntax.
Root cause: the hardcoded test alert built by
sendTestMsgcarries noinstancelabel and nogroupKey, whileAlibabaSmsClientImplassumes real-alert shape and falls through totemplateParam.put("instance", null). Aliyun rejects any request whose template-variable JSON contains a null/blank value, so the test path was broken for every user.Three layers:
AlibabaSmsClientImpl: param building extracted intobuildTemplateParam, every variable falls back to non-blank text (instance→ groupKey → "unknown";content→ summary → description → any annotation → "alert triggered"). Null can no longer reach the JSON, for test and real alerts alike; also removes an NPE whencommonAnnotationsis null.sendTestMsg: the shared test alert now carries aninstancelabel — all five SMS providers read it.${...}syntax with a note that the template must declare exactly these three variables.Boundary: per-rule SMS templates (question 1 in the issue) is a feature request, not covered here — suggested as a separate issue in the discussion. No Aliyun account was available for a live send (custom templates require review), so evidence stops at the outbound JSON — which is what Aliyun validates.
Before / after (the exact
TemplateParamsent to Aliyun for the test alert):Verified: 3 new unit tests (no-null for test-alert shape, no-null for empty alert, real values pass through untouched); full alerter suite 468/468; end-to-end smoke of the shared
send-test-msgpath via the email channel against a local SMTP server (message rendered and delivered).