Skip to content

[fix] allow long threshold expr when binding many monitors - #4330

Open
orangeCatDeveloper wants to merge 1 commit into
apache:masterfrom
orangeCatDeveloper:fix/issue-4171-expr-length
Open

[fix] allow long threshold expr when binding many monitors#4330
orangeCatDeveloper wants to merge 1 commit into
apache:masterfrom
orangeCatDeveloper:fix/issue-4171-expr-length

Conversation

@orangeCatDeveloper

Copy link
Copy Markdown
Contributor

Fixes #4171

Binding more than ~30 monitors to one alert rule fails with a validation error, because each bound monitor appends an equals(__instance__, "...") clause (~65 chars) to the threshold expr, and the field was capped at 2048 characters — 2048 / 65 ≈ 30 bindings.

The fix widens AlertDefine.expr from @Size(2048)/@Column(2048) to @Lob with a @Size(65535) validation cap — the same pattern the codebase already uses for NoticeTemplate.content. Migration V182 alters the column on all three vendors (mysql longtext with an INFORMATION_SCHEMA idempotency guard matching V172/V180, postgresql TEXT, h2 CLOB); widening is lossless for existing rows. The custom validation message was deliberately dropped so the default hibernate-validator message stays localized.

Backward compatible: previously valid input remains valid, the new 65535 cap still rejects runaway payloads, and expr is admin-authored config so no new trust boundary.

Verified end-to-end against a real backend (fresh H2, Successfully applied 7 migrations ... now at version v182):

before (2048 cap):
  POST expr=1501 chars (35 bindings)  -> {"code":0,"msg":"Add success"}
  POST expr=2296 chars (50 bindings)  -> {"code":1,"msg":"Size.alertDefine.expr:size must be between 0 and 2048"}
                                          (verbatim the error reported in the issue)

after (lob + 65535 cap):
  POST the same 2296-char expr        -> {"code":0,"msg":"Add success"}
  read back                           -> expr length 2296, stored intact
  POST 65536 chars                    -> {"code":1,"msg":"Size.alertDefine.expr:size must be between 0 and 65535"}

@orangeCatDeveloper
orangeCatDeveloper force-pushed the fix/issue-4171-expr-length branch from a5a8100 to b31d988 Compare August 17, 2026 12:13
Binding monitors appends an equals(__instance__, ...) clause per monitor
to the threshold expr, so the 2048-char limit capped bindings at ~30.
Widen expr to a lob with a 65535 validation cap (V182).
@orangeCatDeveloper
orangeCatDeveloper force-pushed the fix/issue-4171-expr-length branch from b31d988 to 69547ff Compare August 18, 2026 06:22
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.

[BUG] <title>Association monitoring: Cannot add more than 30 monitoring items (Size.alertDefine.expr 0-2048)

1 participant