The GitHub Actions job "Required Checks" on texera.git/main has failed. Run started by GitHub user github-merge-queue[bot] (triggered by github-merge-queue[bot]).
Head commit for run: e9e5fda4bbd010ce4f096d806a082f2eebaafed8 / Kunwoo (Chris) <[email protected]> fix(workflow-core): fail a presigned dataset download that ends before its Content-Length (#9348) ### What changes were proposed in this PR? `LakeFSFileDocument` opened presigned URLs with `new URL(url).openStream()`. When a proxy closes the connection before the declared `Content-Length` (for example, the gateway's 15s request timeout on a multi-GB download), `HttpURLConnection` reports an ordinary end of stream. So `asInputStream()` callers got a short body with no error, and `asFile()` saved it as the file. The failure then surfaced later as a format error such as Arrow's `missing Magic number`, with different bytes on every attempt. This PR: - Opens presigned URLs through a small `LengthCheckedInputStream`. When the stream ends short of the declared length, it throws an `IOException` that names the file and both byte counts. Streams without a declared length pass through unchanged. - Uses it on both paths that open a presigned URL (with and without a user JWT). - Makes `asFile()` delete its temp file when the copy does not finish, so a failed download no longer leaves a partial file on disk. The copy goes through `Using.resources` and `transferTo`, so a failing close cannot replace the truncation error. The truncation surfaces during the read, after `asInputStream()` has returned, so it does not trigger the LakeFS fallback. The caller gets the error. ### Any related issues, documentation, discussions? Closes #9350, part of #9347. The gateway-side cause (no request timeout on the RustFS route) is fixed separately in #9349. ### How was this PR tested? Added four cases to `LakeFSFileDocumentSpec`, driven by two new modes in its loopback stub. `truncating` declares the full `Content-Length`, sends half the body, and closes. `undeclaredLength` sends the body chunked, with no `Content-Length`. - `asInputStream` fails the read with an `IOException`, instead of ending it early. - `asFile` throws, leaves no `versionedFile*` temp file behind, and a later `asFile` on the same document reads the file in full. - `asFile` leaves no temp file behind when the download cannot start at all (the presign lookup and the LakeFS fallback both fail). - A chunked body with no declared length still reads in full. The first three fail on `main` and pass with this change. The two truncation cases fail with "Expected exception java.io.IOException to be thrown, but no exception was thrown", and the third because `main` leaves the temp file behind. The fourth passes on both, so it pins the pass-through. ``` sbt "WorkflowCore/testOnly org.apache.texera.amber.core.storage.DocumentFactorySpec org.apache.texera.amber.core.storage.model.*" # Tests: succeeded 65, failed 0 sbt "WorkflowCore/scalafixAll --check" WorkflowCore/scalafmtCheckAll # clean ``` We also confirmed it against a real deployment, where a 1.3 GB `.arrow` dataset failed intermittently with `missing Magic number`. With the gateway timeout still in place, the same read now fails with a message saying the download was cut off. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Report URL: https://github.com/apache/texera/actions/runs/42892772451 With regards, GitHub Actions via GitBox
