Skip to content

Fix exception masking in FileSystems.matchSingleFileSpec - #40109

Open
yquaziii wants to merge 1 commit into
apache:masterfrom
yquaziii:fix-filesystem-exception-masking
Open

yquaziii wants to merge 1 commit into
apache:masterfrom
yquaziii:fix-filesystem-exception-masking

Conversation

@yquaziii

Copy link
Copy Markdown

Fixes #40076

Please add a meaningful description for your change here

Description:
This PR fixes a critical observability gap in FileSystems.matchSingleFileSpec.

Previously, if the underlying file system (such as GCS or HDFS) encountered an error and returned a MatchResult with an ERROR status, the actual root-cause exception (e.g., HTTP 403 Forbidden or 500 Internal Server Error) was swallowed by the SDK.

This change extracts the inner IOException from the failed MatchResult's .metadata() method and correctly chains it as the cause in the newly thrown IOException. This ensures the actual failure reason is exposed in the worker logs.

A unit test has been added to FileSystemsTest.java to verify the exception chaining behavior.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • [ X ] Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @kennknowles for label java.

This pull request likely touches a core component ("core" label). Please review with scrutiny.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

java.io.IOException rootCause = new java.io.IOException("403 Forbidden: Fake GCS Error");
MatchResult failedResult = MatchResult.create(MatchResult.Status.ERROR, rootCause);

FileSystem mockFileSystem = mock(FileSystem.class);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to test this without mocking - e.g. by setting up a local filesystem to result in this error, or using an in-memory fake for a blobstore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Improve exception visibility in FileSystems.matchSingleFileSpec to prevent masking of root-cause Exceptions

2 participants