fatmanverse opened a new pull request, #12922:
URL: https://github.com/apache/seatunnel/pull/12922

   Fixes #12917
   
   ### Purpose of this pull request
   
   `JobInfoService#submitJobs` turned the `params` object of every entry into 
an un-encoded `?k=v&k=v` string (`BaseService#mapToUrlParams`) and parsed it 
back with `RestUtil#buildRequestParams(Map, String)`, which splits on `&` and 
`=` and URL-decodes every value. An entry without `params` failed with a 
`NullPointerException`, and values containing `&`, `%`, `+` or `=` were 
rejected or changed.
   
   `submitJobs` now fills the request parameters from the map directly with a 
new `RestUtil#buildRequestParams(Map, Map)`, which applies the same defaults 
(`jobId` null, `isStartWithSavePoint` false) and the same "jobId is required 
with a savepoint" check. `RestUtil#buildConfigList` converts `params` to string 
values, so a missing `params` gives an empty map and a number such as `"jobId": 
123` keeps working; a `params` value that is not a JSON object is rejected with 
a clear message instead of a `ClassCastException`. `mapToUrlParams` has no 
other caller and is removed.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, as a bug fix: `params` may be omitted, and its values are used exactly 
as given in the JSON body. Smaller changes that come with it, none of them 
documented before:
   
   - A value that a client percent-encoded (`"daily%20job"`, `"a%2Bb"`) or that 
contains `+` is no longer URL-decoded. The JSON body never needed URL-encoding; 
`/submit-job` still decodes its query string.
   - A `null` value (`"jobId": null`) is skipped and the default applies, 
instead of becoming the string `"null"`.
   - A `params` value that is not a JSON object is rejected with 
`IllegalArgumentException` (HTTP 400) and a message naming `params`, instead of 
a `ClassCastException` (HTTP 500).
   
   ### How was this patch tested?
   
   - New `RestUtilSubmitJobsParamsTest`: defaults without `params`, verbatim 
values (`sales&ops`, `100%_load`, `a+b`, `x=y`, `daily job`, `a%2Bb`), numeric 
and boolean values, the savepoint check, a non-object `params`, and that 
`params` is not part of the job config. Passes together with 
`RestApiSubmitJobStartWithSavePointTest`, 
`RestApiSubmitJobConfigShadeDecryptTest` and `BaseServletTest` (21 tests) on 
JDK 17.
   - On a Zeta cluster: an entry without `params` failed with 
`NullPointerException` before and is submitted as `SeaTunnel_Job` now; the five 
job names above failed or were changed before and are kept now; a numeric 
`jobId` is used as the job id; `isStartWithSavePoint` without `jobId` is still 
rejected.
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License 
Notice according
     [New License 
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new 
feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If necessary, please update `incompatible-changes.md` to describe the 
incompatibility caused by this 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