[Improve][Connector-V2] cdc migrate option ruleValidation Framework
Purpose of this pull request
Related #11007
- Remove redundant
checkNotNullin CDC ConfigFactory — already covered byoptionRule()declarative validation - Fix Oracle
checkNotNull(originUrl)dead code that madehostname+portbranch unreachable - Fix
database-namesfromoptionaltorequiredin Oracle/Postgres/SqlServer — runtime unconditionally usesdatabaseList.get(0), not providing it causes NPE
Does this PR introduce any user-facing change?
Yes. Users of Oracle/Postgres/SqlServer CDC connectors who omit database-names will now receive a clear configuration validation error instead of a runtime NPE. This is a bug fix — there was no valid use case without database-names for these connectors.
How was this patch tested?
Unit tests in each connector's FactoryTest:
OracleIncrementalSourceFactoryTest.testDatabaseNamesRequired— verifies missing/empty rejected, valid acceptedPostgresIncrementalSourceFactoryTest.testDatabaseNamesRequired— sameSqlServerIncrementalSourceFactoryTest.testDatabaseNamesRequired— same
Existing tests (numeric constraints, table-names notEmpty) continue to pass.
./mvnw test -pl seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql,seatunnel-connectors-v2/connector-cdc/connector-cdc-oracle,seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres,seatunnel-connectors-v2/connector-cdc/connector-cdc-sqlserver,seatunnel-connectors-v2/connector-cdc/connector-cdc-mongodb -Dtest="*FactoryTest" -DfailIfNoTests=false
Thanks for working on this. I re-reviewed the latest head from scratch again, and this time I specifically checked the current branch as it exists now, not the older revision that still experimented with the shared
OptionRulechange.What This PR Fixes
- User pain: several connectors want to express richer validation such as “these options are mutually exclusive, but the chosen one must also be non-empty or satisfy numeric constraints”.
- Fix approach: the PR migrates multiple connector factories to the new
exclusive(...)+ constrainedoptional(...)style and adds factory tests around those rules.- One-line summary: the connector-side direction is reasonable, but the current head still depends on a shared
OptionRulecontract that is not actually part of this branch anymore.Runtime Chain Rechecked
connector factory startup -> XxxIncrementalSourceFactory.optionRule() -> OptionRule.builder() -> exclusive(optionA, optionB) -> optional(optionA, Conditions...) -> ConfigValidator.validate(rule)Key Findings
- The normal runtime path really does hit
optionRule()during connector factory initialization.- The current PR head no longer carries the shared
OptionRulechange that would relax duplicate registration acrossexclusive(...)and constrainedoptional(...).- Because of that, the connector migrations still rely on a contract that
upstream/devdoes not provide.Findings
Issue 1: the migrated factories still build rules that the current shared
OptionRulecontract rejects
- Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/MySqlIncrementalSourceFactory.java:63-69,seatunnel-connectors-v2/connector-cdc/connector-cdc-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mongodb/MongodbIncrementalSourceFactory.java:65-73, plus the same pattern in the Oracle/Postgres/SQL Server factory updates.- Why this is a blocker: the branch now does
exclusive(TABLE_NAMES, TABLE_PATTERN)and thenoptional(TABLE_NAMES, Conditions.notEmpty(...))(same for the other connectors), but the sharedOptionRuleondevstill treats that as a duplicate option registration. So the latest connector code is still depending on a builder behavior that is not present on the current base branch.- Better fix: either bring back the shared
OptionRulesupport change in the same PR, or express the connector-side validation in a way that works with the currentOptionRulecontract.- Severity: High
- Already raised by others: No
Issue 2: the new tests instantiate the broken rule eagerly, so they do not protect the intended migration contract
- Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/test/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/MySqlIncrementalSourceFactoryTest.java:35-38,seatunnel-connectors-v2/connector-cdc/connector-cdc-mongodb/src/test/java/mongodb/source/MongodbIncrementalSourceFactoryTest.java:41-45- Why this is a blocker: both tests initialize
private final OptionRule rule = new ...Factory().optionRule();. If the shared builder contract still rejects the duplicate registration pattern above, the tests are not validating a working migration path; they are just tightly coupled to a branch-local assumption.- Better fix: fix the shared contract mismatch first, then keep these tests as focused validation for the intended option-rule behavior.
- Severity: Medium
- Already raised by others: No
Conclusion: can merge after fixes
- Blocking items
- Issue 1: the connector migration cannot land until the shared
OptionRulecontract it depends on is present on this branch as well.- Issue 2: keep the factory tests, but only after the builder contract mismatch is resolved.
- Suggested non-blocking follow-up
- None beyond the two items above.
Overall, I like the validation direction, but the current head is still split between connector-side usage and base-contract support, so I would not merge it as-is.
@DanielLeens Thank you for your review. The dev branch already supports it. Please use the latest code.
Thanks for calling this out, and sorry for the confusion on my side. I rechecked this specific point against the current dev base rather than my older local checkout, and you are right: dev already contains Conditions plus the newer OptionRule overloads that allow constrained optional(...) entries alongside exclusive(...). So this particular blocker from my last review does not stand on the current base.
Since there is still no new commit after Daniel's latest full review on this PR, I am not starting another full re-review in this round. Please treat this comment only as a correction to that earlier point. If you push another code update, I will re-review the latest head from scratch.
Thanks for the update. I re-reviewed the latest head from the declarative CDC option-rule path down to the actual startup/stop offset consumption path again.
What this PR solves
- User pain: several CDC connectors still reject invalid configs late, from scattered runtime
if/throwchecks instead of at submit time.- Fix approach: move those checks into declarative
OptionRule + Conditions + ConditionExtensionacross the CDC factories.- One-line summary: the migration direction is still right, but the current head still leaves the Oracle / SQL Server offset-mode contract out of sync with the real runtime path.
Runtime path I checked
Job submission -> OracleIncrementalSourceFactory.optionRule() -> SqlServerIncrementalSourceFactory.optionRule() -> startup-mode / stop-mode dependent fields should be validated here Runtime consumption path -> startup config / stop config resolution on the CDC source side -> SPECIFIC / TIMESTAMP modes consume their companion offset/timestamp fields directlyFindings
Issue 1: the latest head still does not declare the mode-dependent offset fields required by the real startup/stop runtime path
Location:
seatunnel-connectors-v2/connector-cdc/connector-cdc-oracle/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/oracle/source/OracleIncrementalSourceFactory.javaseatunnel-connectors-v2/connector-cdc/connector-cdc-sqlserver/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/sqlserver/source/SqlServerIncrementalSourceFactory.javaWhy this is a blocker: On the current head, the factories only declare conditional validation for
STARTUP_MODE=TIMESTAMPandSTARTUP_MODE=INITIAL. The same option rules still do not cover the companion fields for the other offset-driven modes on the real runtime path, including theSPECIFICstartup case and the stop-mode paths that consume explicit timestamp/file/position values.Risk: An incomplete offset-mode config can still pass submit-time validation and only fail later when the CDC source actually tries to build the startup/stop offset.
Best fix: Add the missing mode-specific conditional requirements to the Oracle and SQL Server factories, and add focused negative tests that prove those invalid offset-mode shapes are rejected during
ConfigValidator.validate(...).Severity: High
Current conclusion
I still see a source-level blocker on the current head. The PR is closer, but the declarative validation contract is not yet fully aligned with the real runtime offset path.
Conclusion: can merge after fixes
- Blocking items
- Issue 1: close the remaining startup/stop offset-mode validation gap in the Oracle / SQL Server factories.
- Suggested non-blocking follow-up
- None from this round.
@DanielLeens Thank you for your review. Please pull the latest code for review. Startup Mode and Stop Mode have been added
Rechecked the latest head: the source-level blocker from my previous Daniel round is still closed for me, and the current Build gate is now green on this unchanged head.
At this point I do not see a new code-side blocker from Daniel on this revision. For queue bookkeeping, this branch is still diverged against the latest dev (ahead_by=27, behind_by=12), but because the required Build signal is green now, I am not asking for a sync-only retry from Daniel's side here.
If the repository still needs a write-capable maintainer to refresh the formal review state or dismiss an older visible changes requested entry, that final gate may need to be handled separately from Daniel's source-level recheck.
Rechecked the same unchanged head 87a79e1a601b after the CI / merge-gate fact changed.
Runtime path rechecked
job submission
-> connector SourceFactory validates startup / stop / schema-change options
-> source config is materialized into connector runtime
-> connector reader starts from INITIAL / LATEST / specific startup mode
-> schema-change E2E coverage asserts the intended path per connector
Merge conclusion
Conclusion: source blocker cleared from Daniel's side
- Blocking items
- None from Daniel's source review on this unchanged head.
- Current gate
- The current CI signal is now green: https://github.com/apache/seatunnel/actions/runs/29034709799/job/86176411570
- Daniel only has
READpermission on this repository, so GitHub may still show earlier review state and a write-capable maintainer may still need to handle the final approval / dismissal step.
I do not see a reopened code-side blocker from Daniel on the current head.
Thanks for the update. GitHub is currently reporting merge conflicts between this branch and the latest dev. Could you please sync with the latest dev and resolve the conflicts first? Once that is done and the checks are rerun, I am happy to take another look.