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

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues.
   
   
   ### What happened
   
   Regex option keys are rejected when a job is submitted through the REST 
submit-job API with the
   JSON body, which is that API's default format.
   
   `RestUtil.buildConfig` / `RestUtil.buildConfigList` turn the request body 
into a `Map<String, Object>`
   and call `ConfigBuilder.of(Map)`, which parses it with 
`ConfigFactory.parseMap(objectMap)`. That call
   treats every key as a HOCON path, so a key such as `^t_nova_.*$` (used by
   `multi_table_config.primary_keys`) raises:
   
       org.apache.seatunnel.shade.com.typesafe.config.ConfigException$BadPath: 
path parameter: Invalid path '^t_nova_.*$': Token not allowed in path 
expression: 'end of file'
   
   In `JobInfoService` the JSON branch (`case JSON: default:`) calls 
`RestUtil.buildConfig(...)` and only
   afterwards runs `ConfigShadeUtils.decryptConfig(config)`, so the literal-key 
rebuild that
   `ConfigShadeUtils.processConfig` performs for config files and for the HOCON 
body is never reached
   for this shape.
   
   Effect: a job that uses regex keys in an option map 
(`multi_table_config.primary_keys` is the current
   example) cannot be submitted through the JSON REST body. Submitting the same 
job from a config file
   or with the HOCON body works. Nothing is silently wrong — the job is 
rejected while the config is
   parsed.
   
   Workaround: submit the job from a config file, or use the HOCON body of the 
REST endpoint.
   
   Proposed fix: keep the map keys literal for this entry point as well — for 
example, in
   `ConfigBuilder.of(Map)`, try `ConfigFactory.parseMap(objectMap)` first and, 
when it raises
   `ConfigException.BadPath`, rebuild the map through JSON (the same rebuild 
`processConfig` uses, which
   can be shared between the two call sites). A unit test with a REST-shaped 
map (a regex key next to a
   flat dotted key such as `"job.mode"`) would pin both shapes.
   
   Found while adding `multi_table_config.primary_keys` 
(apache/seatunnel#11878, PR
   apache/seatunnel#12015) and documented there as a known limitation to keep 
that PR scoped.
   
   ### SeaTunnel Version
   
   3.0.0-SNAPSHOT (dev). Reproduced on commit `c15f9fdc5` of PR 
apache/seatunnel#12015.
   
   ### SeaTunnel Config
   
   ```conf
   sink {
     Jdbc {
       url = "jdbc:mysql://localhost:3306/sink"
       driver = "com.mysql.cj.jdbc.Driver"
       username = "root"
       password = "******"
       generate_sink_sql = true
       database = "sink"
       multi_table_config {
         primary_keys {
           "^t_nova_.*$" = ["${primary_key}", "DATA_SOURCE"]
         }
       }
     }
   }
   
   
   The same configuration sent as a JSON body of the REST submit-job endpoint:
   
   
   {"env":{"job.mode":"BATCH"},
    
"source":[{"plugin_name":"FakeSource","row.num":1,"schema":{"fields":{"name":"string"}}}],
    
"sink":[{"plugin_name":"Jdbc","url":"jdbc:mysql://localhost:3306/sink","driver":"com.mysql.cj.jdbc.Driver",
             
"username":"root","password":"******","generate_sink_sql":true,"database":"sink",
             
"multi_table_config":{"primary_keys":{"^t_nova_.*$":["${primary_key}","DATA_SOURCE"]}}}]}
   ```
   
   ### Running Command
   
   ```shell
   curl -X POST "http://localhost:5801/submit-job"; -H "Content-Type: 
application/json" -d @body.json
   ```
   
   ### Error Exception
   
   ```log
   org.apache.seatunnel.shade.com.typesafe.config.ConfigException$BadPath: path 
parameter: Invalid path '^t_nova_.*$':
   Token not allowed in path expression: 'end of file' ('$' not followed by {, 
'end of file' not allowed after '$')
       at 
org.apache.seatunnel.shade.com.typesafe.config.impl.PathParser.parsePathExpression(PathParser.java:...)
       at 
org.apache.seatunnel.shade.com.typesafe.config.impl.PathParser.parsePath(PathParser.java:...)
       at 
org.apache.seatunnel.shade.com.typesafe.config.impl.ConfigImpl.fromPathMap(ConfigImpl.java:...)
       at 
org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory.parseMap(ConfigFactory.java:...)
       at 
org.apache.seatunnel.core.starter.utils.ConfigBuilder.of(ConfigBuilder.java:109)
       at 
org.apache.seatunnel.engine.server.utils.RestUtil.buildConfig(RestUtil.java:76)
   ```
   
   ### Zeta or Flink or Spark Version
   
   Zeta (REST submit path).
   
   ### Java or Scala Version
   
   Java 8 and Java 11.
   
   ### Screenshots
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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