ealeonraz opened a new pull request, #11461:
URL: https://github.com/apache/seatunnel/pull/11461

   ### Purpose of this pull request
   
   Part of #11007 (connector-mqtt slice). Migrates the MQTT connector's option 
validation from imperative `if/throw` checks to declarative `optionRule()` + 
`Conditions.*`, so invalid configs are caught at `--check`/submission time and 
constraints are exposed via option-rule metadata.
   
   Migrated rules:
   
   - **Source** (`MqttSourceFactory`): `qos` must be 0 or 1, `format` must be 
`json`/`text` (case-insensitive, via a shared `MqttFormatValidator` 
`ConditionExtension`), `reconnect_timeout` > 0, `max_queue_size` > 0, and 
`client_id` required **and** non-blank when `clean_session=false`. The 
client_id rule is expressed as a conditional requirement plus a conditional 
`notBlank` value constraint, because conditional value constraints alone are 
skipped when the option is absent — a single rule would silently accept 
`clean_session=false` without a `client_id`.
   - **Sink** (`MqttSinkFactory`): `qos` must be 0 or 1, `format` must be 
`json`/`text`, `batch_size` >= 1.
   
   Kept in runtime code (per the migration guide's "not suitable for 
declarative rules" section): broker connection error handling and the 
serialization-format dispatch `default` branch. No options were renamed and no 
defaults changed.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No config option changes. Invalid option values are now rejected during 
config validation (`OptionValidationException` at `--check`/submission time) 
instead of `IllegalArgumentException` at connector initialization.
   
   ### How was this patch tested?
   
   Existing imperative-validation unit tests were migrated to 
`ConfigValidator`-based tests against the factory option rules, plus new 
boundary cases (qos 0/1 accepted, batch_size 1 accepted, case-insensitive 
formats, and all three client_id scenarios: absent fails, blank fails, present 
passes).
   
   ```
   ./mvnw -pl seatunnel-connectors-v2/connector-mqtt test
   Tests run: 42, Failures: 0, Errors: 0, Skipped: 0
   ```
   
   `./mvnw spotless:apply` and `./mvnw -DskipTests verify` run clean on the 
module.
   
   ### Check list
   
   * [x] No new Jar binary package added
   * [x] No documentation update needed (option semantics unchanged; only the 
enforcement point moved)
   * [x] No incompatible change (`incompatible-changes.md` not affected)
   * [x] Not a new connector (plugin-mapping.properties / seatunnel-dist / 
labeler / e2e / plugin_config unchanged)
   


-- 
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]

Reply via email to