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

   ### Search before asking
   
   - [x] I had searched in the issues and found no similar issues.
   
   ### What happened
   
   `POST /submit-jobs` mishandles the per-job `params` object:
   
   1. An entry without `params` fails with an empty `NullPointerException`, 
although every field of `params` is optional in the docs:
   
   ```
   $ curl -X POST http://127.0.0.1:8080/submit-jobs -H 'Content-Type: 
application/json' -d '[{"env": {...}, "source": [...], "sink": [...]}]'
   {"status":"fail","message":"NullPointerException: "}
   
   java.lang.NullPointerException: null
        at 
org.apache.seatunnel.engine.server.rest.service.BaseService.mapToUrlParams(BaseService.java:1313)
        at 
org.apache.seatunnel.engine.server.rest.service.JobInfoService.lambda$submitJobs$9(JobInfoService.java:504)
   ```
   
   2. Values in `params` are corrupted. `JobInfoService#submitJobs` joins 
`params` into a `?k=v&k=v` string without URL-encoding 
(`BaseService#mapToUrlParams`) and parses it back with 
`RestUtil#buildRequestParams`, which splits on `&`/`=` and URL-decodes every 
value. Measured with `"params": {"jobName": ...}` on `dev` e2957d2:
   
   | `jobName` sent | result |
   | --- | --- |
   | `sales&ops` | `IllegalArgumentException: Invalid Params format in Params.` 
|
   | `100%_load` | `IllegalArgumentException: URLDecoder: Illegal hex 
characters in escape (%) pattern` |
   | `a+b` | job named `a b` |
   | `x=y` | job named `x` |
   | `daily job` | job named `daily job` (correct) |
   
   `POST /submit-job?jobName=...` with the same names, URL-encoded in the query 
string, gives the right job names.
   
   ### Expected behavior
   
   An entry without `params` uses the defaults, and `params` values are used as 
they are given in the JSON body.
   
   ### SeaTunnel Version
   
   dev (3.0.1-SNAPSHOT, e2957d2)
   
   ### Zeta or Flink or Spark Version
   
   Zeta
   
   ### 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