Skip to content

[Test][Connector-V2] Respect source-only JDBC option scope - #12875

Closed
hutiefang76 wants to merge 3 commits into
apache:devfrom
hutiefang76:frank/thirty-jdbc-option-scope-20261019
Closed

hutiefang76 wants to merge 3 commits into
apache:devfrom
hutiefang76:frank/thirty-jdbc-option-scope-20261019

Conversation

@hutiefang76

Copy link
Copy Markdown
Collaborator

Purpose of this pull request

The sink completeness test reflects inherited options and currently expects the source-only numeric_special_value_as_null key added in #12792 to be accepted by the sink. This makes clean dev fail even though the production source/sink rules match the documented scope.

Exclude this key from sink completeness coverage, mirroring the existing source-side scoped exclusion. Add a guard using the actual factories to keep the key accepted by the source and rejected by the sink. Every other inherited sink option remains covered.

Fixes #12874. Yes, I am contributing this test fix to Apache SeaTunnel.

Does this PR introduce any user-facing change?

No. Only the existing test class changes. Production option rules, defaults and parsing behavior are unchanged.

How was this patch tested?

Clean baseline: JdbcOptionRuleCompletenessTest reports two tests with one failure. After the fix:

  • Full JDBC package run: 1,154 JDBC tests, zero failures/errors, six conditional skips; required reactor dependencies also pass.
  • Final focused class: three tests pass, no skips. Repeated after removing redundant value iterations because this validator checks keys only.
  • Root ./mvnw -q -DskipTests verify passes (root verification skips test execution).
  • Spotless and independent full-diff review pass. JDK 17.0.18.
./mvnw -pl seatunnel-connectors-v2/connector-jdbc -am package
./mvnw -pl seatunnel-connectors-v2/connector-jdbc -am \
  -Dtest=JdbcOptionRuleCompletenessTest \
  -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false package
./mvnw -q -DskipTests verify

Check list

  • New JAR license notice: not applicable; no dependency changes.
  • User documentation: not applicable; test-only correction.
  • Incompatible changes: not applicable.
  • Connector registration/E2E/config files: not applicable; no connector runtime code changes.

Implemented, tested, independently reviewed and posted with AI assistance for @hutiefang76.

Exclude the documented source-only numeric option from inherited sink completeness coverage and assert its actual factory key scope.

Fixes apache#12874

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick follow-up on the fallout from #12792, @hutiefang76. This is a small and well-scoped test fix, and I reviewed the full diff against the current dev.

What Problem Does This PR Solve?

JdbcOptionRuleCompletenessTest collects options reflectively from JdbcSinkOptions, which inherits JdbcCommonOptions. After #12792 added numeric_special_value_as_null to the common options (declared only in the source rule), the sink completeness test started to demand it in the sink rule, so dev is red. The PR scopes that key out of the sink check and adds a guard that the key stays accepted by the source and rejected by the sink.

1. Code Change Review

1.1 Core logic

  • Before: collectOptionKeys(JdbcSinkOptions.class, Collections.emptySet()) (every inherited key must be in the sink rule).
  • After: collectOptionKeys(JdbcSinkOptions.class, NOT_SINK_OPTIONS) with NOT_SINK_OPTIONS = {numeric_special_value_as_null}, mirroring the existing NOT_SOURCE_OPTIONS (JdbcOptionRuleCompletenessTest.java, around lines 59-70).
  • New test testSourceOnlyOptionRejectedBySinkRule uses the real JdbcSourceFactory/JdbcSinkFactory option rules with ConfigValidator.validateUnknownKeys: the source accepts the key, the sink throws OptionValidationException naming the key. Runtime path: test-only, no production class is touched.

1.2 Compatibility

Fully compatible. Only a test class changes; no option, default or parsing behavior moves.

1.3 Performance / side effects

None (test only).

1.4 Error handling / logging

No issues. The assertion message includes the key and actual exception text, which is helpful for diagnosis.

Issues: none blocking. (Informational) The guard is deliberately one-directional for this single key; if more source-only keys appear later, adding them to NOT_SINK_OPTIONS plus a similar guard is the natural extension.

2. Code Quality Assessment

  • 2.1 Standards: Javadoc on the class and the new constant explains why the exclusion exists; imports are explicit. Good.
  • 2.2 Tests: the guard fails if the sink starts declaring the key or the source stops declaring it, and the exclusion cannot silently widen because only that one key is listed. Stability: Stable (strictness of the existing test is preserved for every other inherited sink option; the only relaxation is the single documented key, with a compensating guard).
  • 2.3 Docs: not applicable (no user-visible change).

3. Architectural Soundness

Consistent with the existing scoped-exclusion pattern on the source side; minimal and focused.

4. Issue Summary

# Severity Location Summary
- - - No code issues found

5. Merge Recommendation

Conclusion: Ready to merge after fixes

Blockers:

  • CI has not run. CI state (head 6b4777e7): the apache-side Build check is action_required with "Workflow run detection failed": no Build run was found in your fork for this head commit, so none of the compile/unit/IT jobs have actually executed. Notify test workflow and labeler are green. Could you please enable GitHub Actions on your fork (Actions tab) and push/re-run so the Build workflow runs for this head? The branch is 0 commits behind dev, so no sync is needed.

Non-blocking: none.

@nzw921rx

Copy link
Copy Markdown
Member

@fatmanverse

Copy link
Copy Markdown
Contributor

Thanks for catching this. I added JdbcOptionRuleCompletenessTest in #12800, and I can confirm the failure: on dev (e2957d2) the full connector-jdbc unit tests have exactly one failure, testSinkRuleDeclaresAllSinkOptions (unknown option keys: [numeric_special_value_as_null]), on JDK 17.

The fix here looks right to me. NUMERIC_SPECIAL_VALUE_AS_NULL is documented as a PostgreSQL source read option and only the source factory declares it, so excluding it from the sink coverage is the intended scoping, the same way schema is excluded on the source side. The new testSourceOnlyOptionRejectedBySinkRule also keeps the source/sink split from drifting silently.

@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks @fatmanverse for the precise root cause, and @nzw921rx for catching the CI state — both confirmed my own read of the diff.

To close the loop on the two open threads:

  • Substance: I agree with your analysis. NUMERIC_SPECIAL_VALUE_AS_NULL is declared only in the source option rule, so requiring it in the sink rule was an artifact of the completeness test walking all inherited JdbcCommonOptions keys. Excluding it and adding testSourceOnlyOptionRejectedBySinkRule is exactly the right shape — it mirrors the existing NOT_SOURCE_OPTIONS treatment and keeps the source/sink split from silently drifting again. My source-side conclusion on this PR stands: no blockers, and the guard is deliberately one-directional for this single key, which is the right scope for a targeted test fix.
  • CI: this is currently the only thing between the PR and a green run. The Build workflow is not executing on the fork, so GitHub shows no result at all rather than a failing one. @hutiefang76 could you enable GitHub Actions in your fork and re-trigger the run? Reference check run: https://github.com/apache/seatunnel/pull/12875/checks?check_run_id=117839106842

If you hit trouble enabling workflows in the fork, feel free to say so here — several people have hit this and there's usually a quick fix.

@hutiefang76

Copy link
Copy Markdown
Collaborator Author

I checked the fork again on this PR’s current head, 6b4777e7. The Actions permissions API returns enabled: true, and the Build workflow is active, but dispatching it for this branch returns HTTP 422: Actions has been disabled for this repository. No Build run was created.

The full local JDBC suite passed (1,154 tests, 0 failures/errors, 6 existing conditional skips), including the source/sink option checks. I’m still treating remote CI as pending. Is there an upstream-side way to run the checks for this head while the fork dispatch is blocked?

@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks for digging into this, @hutiefang76, and for the precise check on the fork side.

A few facts that may help narrow it down:

  • The Apache-side Build check for head 6b4777e7 is action_required, and it is only a pointer: it needs the real workflow run to exist in your fork. The 422 Actions has been disabled for this repository that you got when dispatching means the fork is not able to run workflows at all right now, so no push or rerun from the PR side will create a run.
  • Your fork did run Build before (the most recent run I can see is from 2026-10-08), so this looks like a state change on the fork or account rather than a repository configuration problem in this PR.
  • As a reviewer I cannot start or approve a run on the Apache side for a fork branch, and I cannot change fork settings, so I would not want to guess a workaround that skips the normal CI gate.

Things worth checking on your side (I cannot see these from here, so this is a suggestion, not a diagnosis):

  1. Open the Actions tab of your fork in the browser and see whether there is a banner asking to enable workflows; click it if present.
  2. In the fork under Settings > Actions > General, confirm that actions are allowed, and check the account Billing page for any Actions usage limit or spending-limit message, because GitHub reports a blocked account like this with the same message.
  3. After it is re-enabled, push an empty commit (or sync the branch with the latest dev, it is 8 commits behind now) so a fresh pull_request run is created.

Your local run of the full JDBC suite (1,154 tests, 0 failures) plus the diff review is good evidence for the change itself, and my source-side conclusion remains: no blockers. A committer will still want the Build result before merge, so if the fork cannot be re-enabled, please say so here and the maintainers can decide how to proceed.

@nzw921rx

Copy link
Copy Markdown
Member
image

Please follow this process

@hutiefang76

hutiefang76 commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator Author

The fork-wide Actions gate was still disabled on the Actions page despite the permissions API reporting enabled and Build active. Re-enabling it there restored actual execution.

I pushed c5a11f7732, merged with dev 1ce2d78156. The three option-rule regressions, root formatting and root verify passed on that integration; the complete PR still changes only JdbcOptionRuleCompletenessTest.

Build on this head is now executing. The Linux JDK 11/17 unit jobs and edge-agent builds fail in the same unrelated LLMBooleanOutputTest legacy-stream case. I independently reproduced that on unmodified dev: 42 LLM cases, one InvalidClassException caused by the historical superclass UID. I filed #12929 with the source/UID evidence and a compatibility-boundary question, separately from this JDBC test fix. Remote CI is not green yet.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow-up push, @hutiefang76, and for working through the fork Actions gate so the Build workflow now actually executes. I re-reviewed the full diff at the new head c5a11f77 (the branch is now merged with dev at 1ce2d781; the PR is 2 commits ahead and 0 behind).

What Problem Does This PR Solve?

JdbcOptionRuleCompletenessTest reflects options from JdbcSinkOptions, which inherits JdbcCommonOptions. Since #12792 added numeric_special_value_as_null (declared only in the source rule), the sink completeness test demands it in the sink rule and dev goes red. The PR scopes that key out of the sink check and adds a guard that the key stays accepted by the source and rejected by the sink.

1. Code Change Review

1.1 Core logic

  • testSinkRuleDeclaresAllSinkOptions now calls collectOptionKeys(JdbcSinkOptions.class, NOT_SINK_OPTIONS) with NOT_SINK_OPTIONS = {numeric_special_value_as_null}, mirroring the existing NOT_SOURCE_OPTIONS.
  • New testSourceOnlyOptionRejectedBySinkRule uses the real JdbcSourceFactory / JdbcSinkFactory option rules with ConfigValidator.validateUnknownKeys: the source accepts the key, the sink throws OptionValidationException whose message names the key.
  • Runtime path: test-only; no production class is touched (gh pr diff shows exactly one file). The Javadoc was extended since my last read to explain the scoped-exclusion contract; it is accurate.

1.2 Compatibility

Fully compatible. Only a test class changes; no option, default or parsing behavior moves.

1.3 Performance / side effects

None.

1.4 Error handling and logging

The assertion message includes the key and the actual exception text. No issues.

Status of my earlier points

  • Earlier source-side conclusion: no code blockers. Still holds on the new head.
  • Earlier blocker "CI has not run": resolved. Build now runs on the fork (run 39427092019). It is not green, see below.

2. Code Quality

2.1 Standards

Explicit imports, Javadoc on the class and the new constant, spotless is expected to be clean (the Build run got past formatting into the unit-test stage).

2.2 Tests and stability

  • The new guard fails if the sink ever starts declaring the key, or if the source stops declaring it. The exclusion cannot widen silently because exactly one key is listed. The strictness of the existing sink completeness test is preserved for every other inherited option.
  • Stability rating for the touched tests (JdbcOptionRuleCompletenessTest.java, the NOT_SINK_OPTIONS constant and testSourceOnlyOptionRejectedBySinkRule): Stable.

2.3 Docs

Not applicable (test-only, no user-visible change).

3. Architectural Soundness

Consistent with the existing source-side scoped exclusion; minimal and focused.

CI state for head c5a11f77

The Apache-side Build check is fail; it is a pointer to the fork run, so I read the real jobs in the fork:

  • unit-test (JDK 11 and 17, Ubuntu and Windows) and both edge-agent-it jobs fail in the same single case, LLMBooleanOutputTest.readsLegacyFactoryWrapperWithValidationDisabled (InvalidClassException ... AbstractMultiCatalogTransform; local class incompatible: stream classdesc serialVersionUID = 7090258061839605137, local class serialVersionUID = -3241928148724104003). That test and the transform sources it touches are not in this diff (seatunnel-transforms-v2, merged earlier in #12194), and your note that it also reproduces on unmodified dev (tracked as #12929) matches the log. The JDBC unit tests are not the failing ones.
  • updated-modules-integration-test-part-8 (17, ubuntu-latest) fails in MetalakeIT.startUp:158 with a ConditionTimeout after ~969 s while starting its container, which is an environment/startup timeout in an IT that this test-only change cannot influence.
  • mysql-cdc-connector-it (11) was cancelled.

So I read the red state as unrelated to the diff, but it is still red, and I cannot call the PR mergeable until it is green. One more point from the thread: @nzw921rx's latest comment points at a required process screenshot that I cannot render here, so please follow what it asks.

4. Issue Summary

# Severity Location Summary
- - - No code issues found.

5. Merge Recommendation

Conclusion: Ready to merge after fixes

Blockers (CI only, not source):

  • Build must be green on the final head. Currently red on LLMBooleanOutputTest (pre-existing on dev, #12929) and a MetalakeIT startup timeout. Once #12929 is fixed on dev and this branch is synced (or the flaky IT is re-run), the PR should be good to go.

Non-blocking: none. Nice work keeping this PR to a single focused test file.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for keeping this branch current, @hutiefang76. The new head e0785877 is a merge of the latest dev (bab2d089, the Parquet NPE fix #11516) into your branch, and I re-read the whole current diff rather than only the delta.

What Problem Does This PR Solve?

  • User pain point: since #12792 added numeric_special_value_as_null to the shared JdbcCommonOptions (declared only in the source rule), JdbcOptionRuleCompletenessTest.testSinkRuleDeclaresAllSinkOptions demands it in the sink rule and fails on dev.
  • Fix approach: scope the key out of the sink completeness check with NOT_SINK_OPTIONS, and add a guard that the key stays accepted by the source rule and rejected by the sink rule.
  • Summary: a one-file, test-only repair that restores a green JDBC option completeness check without weakening it for any other option.

1. Code Change Review

1.1 Core logic

  • testSinkRuleDeclaresAllSinkOptions now collects sink keys with NOT_SINK_OPTIONS = {numeric_special_value_as_null}, mirroring the existing NOT_SOURCE_OPTIONS.
  • testSourceOnlyOptionRejectedBySinkRule runs the real JdbcSourceFactory / JdbcSinkFactory option rules through ConfigValidator.validateUnknownKeys: the source accepts the key, the sink throws OptionValidationException whose message names the key.
  • Runtime path: test-only. gh pr diff shows exactly one file (JdbcOptionRuleCompletenessTest.java); no production class, option default or parsing behavior moves.
  • Since my last read the only new content is the merge from dev (ahead_by 3, behind_by 0); the test file diff is identical to the one I reviewed at c5a11f77.

1.2 Compatibility

Fully compatible. No option, default, SPI or serialization change.

1.3 Performance and side effects

None (test only).

1.4 Error handling and logging

The guard's assertion message includes the key and the actual exception text, which makes a future regression easy to diagnose. No issues.

Status of earlier points

  • Source-side conclusion: no code issues; still holds on this head.
  • Process request from @nzw921rx (follow the required CI process shown in the screenshot): the fork Build is now executing for this head, so the CI-enablement part is resolved.

2. Code Quality

2.1 Standards

Explicit imports, Javadoc on the class and on the new constant explaining the scoped-exclusion contract. Nothing to add.

2.2 Tests and stability

  • The new guard fails if the sink starts declaring the key or the source stops declaring it, and the exclusion cannot silently widen because exactly one key is listed. Strictness of the existing sink completeness check is preserved for every other inherited option.
  • Stability rating for JdbcOptionRuleCompletenessTest.java (the NOT_SINK_OPTIONS constant and testSourceOnlyOptionRejectedBySinkRule): Stable. No sleeps, ports, containers or ordering dependence.

2.3 Docs

Not applicable (test-only, no user-visible change).

3. Architectural soundness

Consistent with the existing source-side scoped exclusion; minimal and focused, one problem per PR.

CI state for head e0785877

At the time of this review the apache-side Build check is pending and the fork run for this exact head (queued as run 39545233263 in your fork) had not started executing jobs yet, so there is no result to judge. I am not drawing any conclusion from the previous head's result for this one. For awareness, the previous head failed only in LLMBooleanOutputTest.readsLegacyFactoryWrapperWithValidationDisabled (InvalidClassException on AbstractMultiCatalogTransform), which this diff does not touch; #12929 tracking it is still open, so dev itself is expected to keep that one unit-test case red until it is fixed. Please rerun only the failed jobs once the run finishes if something unrelated shows up.

4. Issue Summary

# Severity Location Summary
- - - No code issues found.

5. Merge Recommendation

Conclusion: Ready to merge after fixes

Blockers (CI only, not source):

  • Build must be green on the final head. It is still pending, and a known unrelated failure (#12929) may keep the unit-test matrix red until that is fixed on dev.

Non-blocking: none. Nice work keeping this to a single focused test file, and thank you for the quick, careful follow-ups.

@DanielLeens

Copy link
Copy Markdown
Contributor

A CI-status follow-up on the unchanged head e0785877946839775177cbb234b364b0ebd534f1: my earlier note described Build as pending/in progress. That fact is obsolete. The current head's fork Build has completed with failure. The four unit-test matrix legs are red; the JDK 11 Ubuntu log I inspected fails at LLMBooleanOutputTest.readsLegacyFactoryWrapperWithValidationDisabled failing with InvalidClassException on AbstractMultiCatalogTransform. The edge-agent-it lanes are also red; the inspected JDK 11 Linux log stops at the same transform test.

I checked the owning code on latest dev (99ea16b9d6bdce452d4c4955581ccc7236a81bbd) and the upstream tracking state: #12929 remains open, and its proposed fix #12938 is still open rather than present in the base. This is outside this PR's diff. Syncing current dev alone will not fix that observed failure. Please keep this PR focused; once #12938 lands in dev, sync the base and rerun the affected failed jobs for the resulting head. There is no need to add unrelated transform serialization changes here.

My earlier source-level conclusion remains unchanged: no outstanding source blocker from my side. This is a CI follow-up, not a new full code review or formal approval. The branch is currently ahead 3, behind 9, compare diverged, with no merge conflict; the behind fact is recorded separately from the pending upstream fix. A green head-specific Build and write-capable maintainer approval are still required. Thanks for the contribution and patience with the shared CI failure.

@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks for your patience. The upstream status has changed since my preceding note: #12938 merged into dev at 2026-10-22 10:26 UTC (merge cc54bb433357b4cb45db9cd5d0743589c3111b79). I checked that current dev contains the merge and that its diff restores the historical AbstractMultiCatalogTransform serialization UID and makes the construction-only config transient. My earlier instruction to wait for that fix is now superseded.

The archived-wrapper LLMBooleanOutputTest.readsLegacyFactoryWrapperWithValidationDisabled / InvalidClassException is the shared unit-test failure identified in the preceding review (affected job). This head is still e0785877946839775177cbb234b364b0ebd534f1; the current dev comparison is diverged, ahead 3 / behind 11. Please sync with the latest dev and rerun the affected unit checks first, plus any stage whose log showed the same archived-wrapper error. Keep unrelated transform-serialization patches out of this PR. This is a targeted remedy for that known upstream failure, not a claim that syncing fixes every failed stage.

Other failed job families in the same head's run are edge-agent-it. Their causes/results remain separate; this upstream patch does not establish that they pass. My previous source-level conclusion is unchanged. Required CI and the final write-capable maintainer review remain gates. This is a CI-status follow-up only, with no new source findings or fresh full-review claim.

@hutiefang76

Copy link
Copy Markdown
Collaborator Author

I checked the merged dev (4dcfa28c) on JDK 17: all 3 JdbcOptionRuleCompletenessTest cases and all 42 LLMBooleanOutputTest cases pass, including the archived-wrapper fixture. Dev already contains both the source-only option exclusion and the source/sink factory guard from this PR through #12938.

I compared the remaining diff and found no separate behavior fix left to land; the differences are comments, naming and assertion diagnostics. I have not pushed a redundant sync commit. This is focused local verification of dev, not a green Build for the unchanged PR head. It looks fully covered by #12938; I have left the PR open for your review of that conclusion.

@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks for the careful follow-up, @hutiefang76. I re-checked your conclusion against the code and I agree with it.

Evidence on head e0785877946839775177cbb234b364b0ebd534f1 versus current dev (4dcfa28ccc8):

  • JdbcOptionRuleCompletenessTest on dev already defines NOT_SINK_OPTIONS (line 59) with JdbcCommonOptions.NUMERIC_SPECIAL_VALUE_AS_NULL, and already passes it to collectOptionKeys(JdbcSinkOptions.class, NOT_SINK_OPTIONS) (line 73). It also already has the source-accepts / sink-rejects guard test (testNumericSpecialValueAsNullIsSourceOnly, line 77) that uses the real JdbcSourceFactory and JdbcSinkFactory.
  • The file's last change on dev is cc54bb4 ([Fix][Transform-V2] Restore archived LLM wrapper deserialization #12938), so the sink-completeness failure from [Bug][JDBC][Test] Sink option completeness test includes the source-only numeric option #12874 no longer reproduces on dev.
  • The diff between this head and dev for that single file is only a Javadoc paragraph, Collections.singleton replaced by an equivalent unmodifiable HashSet, a renamed test, and a more descriptive assertion message. There is no behavior or coverage change, so nothing in this PR is left to land.

Since the original goal is already satisfied on dev, I would suggest not spending more effort on this branch: no sync or rerun is needed to make it mergeable, because the intended fix is already merged. The branch is also currently conflicting with dev (ahead 3, behind 11), so keeping it open would only mean resolving conflicts for cosmetic changes. If you still want the Javadoc and naming polish, it would be better as a fresh small PR rebased on current dev; otherwise it is reasonable for you to close this one, referencing #12874 and #12938. I will leave the close decision to you or a committer.

Thanks again for the quick root-cause on #12874 and for being upfront that the fix was covered.

@hutiefang76

Copy link
Copy Markdown
Collaborator Author

Closing this as superseded by #12938. Current dev already excludes the source-only option from sink completeness and tests source acceptance / sink rejection, so #12874 is covered. I verified the current-dev tests; the remaining diff here is only comments, naming and equivalent collection setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][JDBC][Test] Sink option completeness test includes the source-only numeric option

4 participants