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

   ### Purpose of this pull request
   
   Yes, I am contributing this focused fix to Apache SeaTunnel.
   
   Fixes #12918, following the [confirmed scope and 
assignment](https://github.com/apache/seatunnel/issues/12918#issuecomment-6340368560).
   
   `BaseServlet.requestBody()` previously let the servlet reader fall back to 
ISO-8859-1 for a text body without a declared charset. Converting the resulting 
string to UTF-8 afterwards could not recover the original characters. This 
change sets UTF-8 before obtaining the reader when the encoding is absent, 
preserves supported explicit charsets, and rejects unsupported declarations 
through the existing HTTP 400 exception handler.
   
   The shared-reader audit covers `SubmitJobServlet`, `SubmitJobsServlet`, 
`StopJobServlet`, `StopJobsServlet`, `EncryptConfigServlet`, 
`UpdateTagsServlet`, and `LoggersServlet`. Query/form-parameter parsing, 
request-body newline handling, runtime job execution and multipart config-file 
decoding are unchanged. The separate query/body-order fix in #12921 is not 
included.
   
   ### Does this PR introduce any user-facing change?
   
   Yes. UTF-8 text such as `job.name = "café-数据"` now round-trips with 
`Content-Type: text/plain` without requiring a charset suffix. Explicit UTF-8, 
ISO-8859-1 and UTF-16LE requests remain supported. An unsupported declaration 
returns HTTP 400 with an `Unsupported request charset` message rather than 
being ignored or becoming an HTTP 500.
   
   The English and Chinese REST API v2 documentation now describes the encoding 
contract, its scope, and a `curl --data-binary` example. No dependencies, 
configuration options, connector registrations or checkpoint formats are 
changed.
   
   ### How was this patch tested?
   
   Local environment: Windows, Temurin JDK 11.0.32 and Maven 3.9.9. The patch 
is based on `dev` at `4dcfa28c`.
   
   The existing real-Jetty `RestApiSubmitJobConfigShadeDecryptTest` is 
extended, not replaced with mocked servlet requests:
   
   - HOCON and SQL submission with `text/plain`.
   - JSON single and batch submission with both `application/json` and 
`text/plain`.
   - Each submission variant with an absent charset, UTF-8, ISO-8859-1, and 
UTF-16LE; assert the exact non-ASCII job name and returned job ID.
   - Non-ASCII `/encrypt-config` bodies with text and JSON content types.
   - Unsupported charset rejection across all seven shared-reader endpoints.
   - Existing encrypted-config and multipart upload regression cases remain in 
the same class.
   
   Before the production change, the initial corrected 32-case suite had 10 
failures (three decoding cases and seven unsupported-charset cases). All 32 
passed after the fix; the final matrix additionally covers JSON submitted as 
`text/plain`.
   
   The existing `RestApiIT.testSubmitJobWithHoconFormat` now submits UTF-8 
bytes without an automatically appended charset and checks the non-ASCII job 
name through both v1 and v2 URLs.
   
   Results:
   
   - `RestApiSubmitJobConfigShadeDecryptTest`: **40 passed**, zero 
failures/errors/skips; engine-server `verify` passed.
   - `BaseServletTest`, `ExceptionHandlingFilterTest`, `OptionRulesApiTest`, 
`RestApiHttpBasicTest`, and `RestApiSubmitJobStartWithSavePointTest`: **19 
passed**, zero failures/errors/skips.
   - The 66-module prerequisite reactor for `connector-seatunnel-e2e-base` 
passed `spotless:apply install` with tests skipped, including compilation of 
the updated integration test.
   - Focused `RestApiIT#testSubmitJobWithHoconFormat`: attempted, but **not 
passed**. The existing file-sink setup fails before the REST assertions because 
this Windows environment has neither `HADOOP_HOME` nor `hadoop.home.dir` 
configured (`Shell.getWinUtilsPath` / file-catalog save-mode initialization). 
This fixture limitation is not suppressed or changed in this PR.
   - `git diff --check`: passed.
   - Repository-wide offline `verify -DskipTests`: attempted but 
**incomplete**, stopped after roughly four minutes in Maven 
remote-resource/dependency metadata processing without a result. It is not 
counted as a pass. The targeted engine-server verification and 66-module 
prerequisite reactor above completed successfully.
   
   Commands (from the repository root; local runs also used offline mode and 
the existing Maven cache):
   
   ```shell
   ./mvnw -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base 
-am spotless:apply install -DskipTests -DskipIT=true -Dskip.ui=true
   ./mvnw -pl seatunnel-engine/seatunnel-engine-server 
-Dtest=RestApiSubmitJobConfigShadeDecryptTest -DskipIT=true -Dskip.ui=true 
spotless:apply verify
   ./mvnw -pl seatunnel-engine/seatunnel-engine-server 
-Dtest=BaseServletTest,ExceptionHandlingFilterTest,OptionRulesApiTest,RestApiHttpBasicTest,RestApiSubmitJobStartWithSavePointTest
 surefire:test
   ./mvnw -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base 
-DskipUT=true -DskipIT=false '-Dit.test=RestApiIT#testSubmitJobWithHoconFormat' 
failsafe:integration-test failsafe:verify
   ./mvnw -q -DskipTests -DskipIT=true -Dskip.ui=true verify
   ```
   
   ### CI status
   
   This PR is intentionally a draft until a genuine head-specific GitHub Build 
passes. Earlier PRs from this fork encountered an Actions activation/dispatch 
gate; local results are not a substitute for that CI run. No empty commits are 
included to work around the gate.
   
   ### Check list
   
   - [x] Existing real-server tests extended; existing engine integration test 
updated.
   - [x] English and Chinese documentation updated.
   - [x] No new binary dependency or connector registration changes.
   - [x] Charset handling only; #12921's form/query behavior remains separate.
   


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