fatmanverse opened a new issue, #12796:
URL: https://github.com/apache/seatunnel/issues/12796

   ### Search before asking
   
   - [x] I had searched in the issues and found no similar issues.
   
   ### What happened
   
   `seatunnel.sh --check` and `--dry-run static|connect` reject a valid Jdbc 
sink config that uses the documented `table` option:
   
   ```
   Static analysis failed: ErrorCode:[API-02], ErrorDescription:[Option item 
validate failed] -
   Connector 'Jdbc' has unknown option keys: [table]. Please check for typos.
   ```
   
   The same config runs fine when submitted normally, so the checker reports a 
false positive.
   
   The root cause is that `JdbcSinkFactory#optionRule()` does not declare every 
option the sink reads. `ConfigValidator#validateUnknownKeys` (used by 
`--check`, `--dry-run` and the Flink/Spark config validation) only accepts keys 
declared in the rule, so any documented sink option that is missing from the 
rule is rejected.
   
   Options that the Jdbc sink reads (`JdbcSinkConfig#of`, 
`JdbcConnectionConfig#of`, `JdbcSinkFactory`) and documents in 
`docs/en/connectors/sink/Jdbc.md`, but does not declare in `optionRule()`:
   
   - `table`
   - `connect_timeout_ms`, `socket_timeout_ms`
   - `properties`
   - `use_kerberos`, `kerberos_principal`, `kerberos_keytab_path`, `krb5_path`
   - `access_key_id`, `secret_access_key`, `region`
   
   `schema`, `decimal_type_narrowing`, `int_type_narrowing` and 
`handle_blob_as_string` are also read but not declared.
   
   The Jdbc source has the same gap for options read by the shared 
`JdbcConnectionConfig#of` and documented in 
`docs/en/connectors/source/Jdbc.md`: `connect_timeout_ms`, `socket_timeout_ms`, 
`handle_blob_as_string`, `use_kerberos`, `kerberos_principal`, 
`kerberos_keytab_path` and `krb5_path`.
   
   ### How to reproduce (verified on `dev` 42d2aab)
   
   ```hocon
   env {
     parallelism = 1
     job.mode = "BATCH"
   }
   source {
     FakeSource {
       plugin_output = "fake"
       row.num = 10
       schema = { fields { id = int, name = string } }
     }
   }
   sink {
     Jdbc {
       plugin_input = "fake"
       url = "jdbc:mysql://127.0.0.1:3306/test"
       driver = "com.mysql.cj.jdbc.Driver"
       username = "root"
       password = "******"
       generate_sink_sql = true
       database = "test"
       table = "t_sink"
       primary_keys = ["id"]
     }
   }
   ```
   
   ```
   bin/seatunnel.sh --config job.conf --check
   bin/seatunnel.sh --config job.conf --dry-run static
   ```
   
   Both fail with `Connector 'Jdbc' has unknown option keys: [table]`. If you 
remove the `table` line, the check passes. Running the job without `--check` 
succeeds.
   
   ### Expected behavior
   
   All documented Jdbc source and sink options pass `--check` and `--dry-run`. 
Truly unknown keys should still be rejected.
   
   ### SeaTunnel Version
   
   dev (3.0.1-SNAPSHOT, 42d2aab)
   
   ### Running Command
   
   ```shell
   bin/seatunnel.sh --config job.conf --check
   ```
   
   ### Zeta or Flink or Spark Version
   
   Zeta (affects Flink/Spark config validation as well, since they share 
`ConfigValidationUtils`)
   
   ### Java or Scala Version
   
   JDK 11
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   


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