amalsaidov opened a new pull request, #13237: URL: https://github.com/apache/seatunnel/pull/13237
Yes, happy to contribute this to Apache SeaTunnel. ### Purpose of this pull request Part of #11007 (migrate connector validation to declarative `OptionRule`). The MQTT sink validated two options imperatively inside `MqttSinkWriter`: `qos` had to be `0` or `1`, and `batch_size` had to be `>= 1`. Both checks ran only when the writer was constructed, so a bad value passed `--check` and failed later. Both options are already declared in `MqttSinkFactory.optionRule()`; this moves their bounds into the rule. ### What changed - `MqttSinkFactory.optionRule()` now declares `qos` with `greaterOrEqual(0).and(lessOrEqual(1))` and `batch_size` with `greaterOrEqual(1)`. - `FactoryUtil.createAndPrepareSink()` runs `ConfigValidator` against the factory rule before the sink is built, so these values are now rejected at `--check` time with an `OptionValidationException` that names the offending option. - Removed the two imperative range checks from `MqttSinkWriter`. The `format` check stays in the writer because it is enum-style semantic validation, not a numeric range. - No option name, type, default, or accepted range changed. ### Does this PR introduce any user-facing change? An out-of-range `qos` or a `batch_size` below `1` is now reported at `--check` time with a clear validation error naming the option, instead of failing later during writer construction. Valid configurations are unaffected. ### How was this patch tested? - Extended `MqttSinkFactoryTest` to validate the rule through `ConfigValidator`: accepted defaults and valid ranges (`qos` 0 and 1, `batch_size` 1 and a large value), rejected `qos` `-1` and `2`, and rejected `batch_size` `0` and `-1`, asserting the message names the option. - Removed the `MqttSinkWriterTest` case that asserted the writer rejects `qos = 2`, since that bound is now enforced at the factory. The format-rejection case and the connection and write tests are unchanged. ``` ./mvnw -pl seatunnel-connectors-v2/connector-mqtt -am -DskipTests install ./mvnw -pl seatunnel-connectors-v2/connector-mqtt test ``` Both pass on JDK 21. --- AI-assisted; directed, reviewed and tested by the author. -- 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]
