orangeCatDeveloper opened a new pull request, #4330:
URL: https://github.com/apache/hertzbeat/pull/4330
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"}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]