Repository navigation
fix(file-service): apply LakeFS error handling to all call sites - #5607
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5607 +/- ##
============================================
+ Coverage 52.45% 52.63% +0.17%
- Complexity 2485 2496 +11
============================================
Files 1071 1071
Lines 41366 41376 +10
Branches 4442 4445 +3
============================================
+ Hits 21698 21777 +79
+ Misses 18399 18320 -79
- Partials 1269 1279 +10
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
LGTM, @suyashj1231 did you test normal features on local development? like upload/download/use dataset in workflow?
|
Hi @aicam , yes tested it locally to be sure. Ran the file-service from this branch inside the full single-node docker stack (everything else same), then just used the app normally in the browser: Workflow:
also tried hitting a missing file and got a clean 404 with the new "LakeFS resource not found" message instead of a raw 500, so the handler is doing its thing outside the failure-injection tests too.
|
Thanks |
Yicong-Huang
left a comment
There was a problem hiding this comment.
Hi @suyashj1231 could you please add more tests to make coverage happy? The current coverage is too low. See #5607 (comment)
…points The patch-coverage gaps in apache#5607 were concentrated in four endpoints the suite never called: getDataset (repository size), uploadOneFileToDataset, versionZip, and presign-download. Add happy-path and LakeFS failure-injection tests for each, plus a response-body case for LakeFSExceptionHandler. uploadOneFileToDataset was previously untestable: MockLakeFS hardcoded the LakeFS pre-signed endpoint to localhost:9000 while MinIO's host port was dynamically mapped, so presigned part uploads could never reach MinIO. Reserve a free host port, pin MinIO's 9000 to it, and point the pre-signed endpoint at the same port.
|
Added tests to cover the missing lines. While doing this I found uploadOneFileToDataset was actually untestable before, the test setup pointed LakeFS's presigned URLs at the wrong MinIO port, so I fixed that too. |
### What changes were proposed in this PR? #4177 introduced `LakeFSExceptionHandler.withLakeFSErrorHandling`, but only the multipart-upload and dataset-version paths used it. The remaining LakeFS call sites in `DatasetResource` either leaked raw `io.lakefs.clients.sdk.ApiException` to Dropwizard (an opaque 500 for the frontend) or caught `Exception` and rewrapped it as a generic 500, discarding the real LakeFS status code (401/403/404/409/...). ``` Before: LakeFS 404 -> raw ApiException / catch(Exception) -> 500 "Failed to ..." After: LakeFS 404 -> withLakeFSErrorHandling -> 404 "Error while deleting file 'a.csv' ...: LakeFS resource not found. ..." ``` Changes: | Change | Where | | --- | --- | | New overload `withLakeFSErrorHandling(operation: String)(call)` that prefixes the user-visible message with the failed operation | `LakeFSExceptionHandler.scala` | | 8 bare LakeFS calls now wrapped (size lookup, version listing, zip download, presigned URLs, cover image) | `DatasetResource.scala` | | 5 `catch Exception -> generic 500` blocks now use the handler; compensation logic (DB rollback on failed repo init, multipart abort) is preserved, and the abort-on-failure cleanup no longer masks the original error | `DatasetResource.scala` | Intentionally unchanged: best-effort cleanup sites that deliberately swallow errors, the per-dataset skip in `listDatasets`, and the `FileService` startup health check (failing fast at boot is correct there). ### Any related issues, documentation, discussions? Closes #4176 ### How was this PR tested? New `LakeFSExceptionHandlerSpec` (7 unit cases): status-code mapping (400/401/403/404/409/4xx/5xx/unknown), operation context included in the frontend-visible message, success passthrough, and non-LakeFS exceptions propagating untouched. New integration case in `DatasetResourceSpec`: deleting a dataset whose LakeFS repository does not exist now yields `NotFoundException` (404) instead of a generic 500. ``` sbt "FileService/testOnly org.apache.texera.service.util.LakeFSExceptionHandlerSpec" # Tests: succeeded 7, failed 0 sbt "FileService/testOnly org.apache.texera.service.resource.DatasetResourceSpec" # Tests: succeeded 94, failed 0 (Testcontainers: LakeFS 1.51 + MinIO + Postgres) ``` `sbt FileService/scalafixAll` and `sbt FileService/scalafmtAll` produce no further diff. ### Was this PR authored or co-authored using generative AI tooling? Yes, partially. I (Suyash Jain) worked on this PR together with Claude Code as a pair-programming assistant. I reviewed the final diff and ran the unit and Testcontainers-based integration suites locally before opening the PR. (backported from commit 7b1c8dc) Generated-by: Claude Code (Claude Opus 4.7)
|
Backport to |
…che#5607) ### What changes were proposed in this PR? apache#4177 introduced `LakeFSExceptionHandler.withLakeFSErrorHandling`, but only the multipart-upload and dataset-version paths used it. The remaining LakeFS call sites in `DatasetResource` either leaked raw `io.lakefs.clients.sdk.ApiException` to Dropwizard (an opaque 500 for the frontend) or caught `Exception` and rewrapped it as a generic 500, discarding the real LakeFS status code (401/403/404/409/...). ``` Before: LakeFS 404 -> raw ApiException / catch(Exception) -> 500 "Failed to ..." After: LakeFS 404 -> withLakeFSErrorHandling -> 404 "Error while deleting file 'a.csv' ...: LakeFS resource not found. ..." ``` Changes: | Change | Where | | --- | --- | | New overload `withLakeFSErrorHandling(operation: String)(call)` that prefixes the user-visible message with the failed operation | `LakeFSExceptionHandler.scala` | | 8 bare LakeFS calls now wrapped (size lookup, version listing, zip download, presigned URLs, cover image) | `DatasetResource.scala` | | 5 `catch Exception -> generic 500` blocks now use the handler; compensation logic (DB rollback on failed repo init, multipart abort) is preserved, and the abort-on-failure cleanup no longer masks the original error | `DatasetResource.scala` | Intentionally unchanged: best-effort cleanup sites that deliberately swallow errors, the per-dataset skip in `listDatasets`, and the `FileService` startup health check (failing fast at boot is correct there). ### Any related issues, documentation, discussions? Closes apache#4176 ### How was this PR tested? New `LakeFSExceptionHandlerSpec` (7 unit cases): status-code mapping (400/401/403/404/409/4xx/5xx/unknown), operation context included in the frontend-visible message, success passthrough, and non-LakeFS exceptions propagating untouched. New integration case in `DatasetResourceSpec`: deleting a dataset whose LakeFS repository does not exist now yields `NotFoundException` (404) instead of a generic 500. ``` sbt "FileService/testOnly org.apache.texera.service.util.LakeFSExceptionHandlerSpec" # Tests: succeeded 7, failed 0 sbt "FileService/testOnly org.apache.texera.service.resource.DatasetResourceSpec" # Tests: succeeded 94, failed 0 (Testcontainers: LakeFS 1.51 + MinIO + Postgres) ``` `sbt FileService/scalafixAll` and `sbt FileService/scalafmtAll` produce no further diff. ### Was this PR authored or co-authored using generative AI tooling? Yes, partially. I (Suyash Jain) worked on this PR together with Claude Code as a pair-programming assistant. I reviewed the final diff and ran the unit and Testcontainers-based integration suites locally before opening the PR. Generated-by: Claude Code (Claude Opus 4.7)








What changes were proposed in this PR?
#4177 introduced
LakeFSExceptionHandler.withLakeFSErrorHandling, but only the multipart-upload and dataset-version paths used it. The remaining LakeFS call sites inDatasetResourceeither leaked rawio.lakefs.clients.sdk.ApiExceptionto Dropwizard (an opaque 500 for the frontend) or caughtExceptionand rewrapped it as a generic 500, discarding the real LakeFS status code (401/403/404/409/...).Changes:
withLakeFSErrorHandling(operation: String)(call)that prefixes the user-visible message with the failed operationLakeFSExceptionHandler.scalaDatasetResource.scalacatch Exception -> generic 500blocks now use the handler; compensation logic (DB rollback on failed repo init, multipart abort) is preserved, and the abort-on-failure cleanup no longer masks the original errorDatasetResource.scalaIntentionally unchanged: best-effort cleanup sites that deliberately swallow errors, the per-dataset skip in
listDatasets, and theFileServicestartup health check (failing fast at boot is correct there).Any related issues, documentation, discussions?
Closes #4176
How was this PR tested?
New
LakeFSExceptionHandlerSpec(7 unit cases): status-code mapping (400/401/403/404/409/4xx/5xx/unknown), operation context included in the frontend-visible message, success passthrough, and non-LakeFS exceptions propagating untouched.New integration case in
DatasetResourceSpec: deleting a dataset whose LakeFS repository does not exist now yieldsNotFoundException(404) instead of a generic 500.sbt FileService/scalafixAllandsbt FileService/scalafmtAllproduce no further diff.Was this PR authored or co-authored using generative AI tooling?
Yes, partially. I (Suyash Jain) worked on this PR together with Claude Code as a pair-programming assistant. I reviewed the final diff and ran the unit and Testcontainers-based integration suites locally before opening the PR.
Generated-by: Claude Code (Claude Opus 4.7)