Skip to content

[#38059] Fix GCS glob matching to support ** and / in object names - #38099

Merged
jrmccluskey merged 8 commits into
apache:masterfrom
hilaryRope:fix/gcs-glob-matching-slash-separator
Jun 12, 2026
Merged

[#38059] Fix GCS glob matching to support ** and / in object names#38099
jrmccluskey merged 8 commits into
apache:masterfrom
hilaryRope:fix/gcs-glob-matching-slash-separator

Conversation

@hilaryRope

Copy link
Copy Markdown
Contributor

Fix GCS filesystem glob matching to handle / in object names and support **

Fixes #38059

Summary

The GCS filesystem's List() method was using filepath.Match() to filter objects, which incorrectly treats / as a path separator. Since GCS object names are flat (with / being just another character), patterns like gs://bucket/** failed to match objects containing /.

Problem

  • filepath.Match treats / as a path separator, so * cannot match across /
  • filepath.Match does not support ** for recursive matching
  • fileio.MatchFiles(scope, "gs://my-bucket/**") silently excluded objects like dir/subdir/file.txt

Solution

Replaced filepath.Match with a custom globToRegex() function:

  • * → matches any characters except / (single path segment)
  • ** → matches any characters including / (recursive)
  • **/ → matches zero or more path segments

This aligns the Go SDK with the Python and Java SDKs.

Testing

Added unit tests for globToRegex() and List() with nested object names.


  • Mention the appropriate issue in your description (for example: addresses #123), if applicable.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where GCS filesystem glob patterns were incorrectly filtered due to the standard library's path-aware matching logic. By implementing a custom regex-based matching system, the GCS connector now properly handles object names containing slashes and supports recursive globbing, ensuring consistent behavior across different Apache Beam SDKs.

Highlights

  • Custom Glob Matching: Replaced the standard library's filepath.Match with a custom globToRegex function to correctly handle GCS object names, which are flat and treat '/' as a standard character.
  • Recursive Matching Support: Added support for the '**' glob pattern to enable recursive matching across GCS object paths, aligning the Go SDK with Python and Java implementations.
  • Comprehensive Testing: Introduced new unit tests for the glob-to-regex conversion logic and verified GCS list operations with nested object structures.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@utafrali utafrali left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The core approach of replacing filepath.Match with a custom globToRegex is correct and well-motivated. The main issue is that ? is translated to . (matches /) while * is explicitly restricted to [^/]*, creating an inconsistency that will surprise callers. There are also minor concerns around the hand-maintained isRegexSpecial list (use regexp.QuoteMeta instead) and the silent swallowing of malformed [ patterns.

Comment thread sdks/go/pkg/beam/io/filesystem/gcs/gcs.go
Comment thread sdks/go/pkg/beam/io/filesystem/gcs/gcs.go
Comment thread sdks/go/pkg/beam/io/filesystem/gcs/gcs.go
Comment thread sdks/go/pkg/beam/io/filesystem/gcs/gcs_test.go
Comment thread sdks/go/pkg/beam/io/filesystem/gcs/gcs_test.go
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @jrmccluskey for label go.

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

@hilaryRope

Copy link
Copy Markdown
Contributor Author

@utafrali all comments addressed, thanks!

@github-actions

Copy link
Copy Markdown
Contributor

Reminder, please take a look at this pr: @jrmccluskey

@jrmccluskey

Copy link
Copy Markdown
Contributor

@gemini-code-assist review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request fixes GCS filesystem glob matching in the Go SDK to correctly handle slashes in object names and support recursive matching with **, aligning its behavior with the Python and Java SDKs. The implementation replaces filepath.Match with a custom globToRegex translator and updates the List operation to use regex-based filtering. Feedback was provided to optimize the generated regular expression by using non-capturing groups for recursive path segments.

Comment thread sdks/go/pkg/beam/io/filesystem/gcs/gcs.go Outdated

@jrmccluskey jrmccluskey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Modify .github/trigger_files/beam_PostCommit_Go.json to trigger the post-commit, which will run all of the Go tests that interact with Dataflow / GCS.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@hilaryRope

Copy link
Copy Markdown
Contributor Author

Modify .github/trigger_files/beam_PostCommit_Go.json to trigger the post-commit, which will run all of the Go tests that interact with Dataflow / GCS.

Thank you @jrmccluskey I did so - apologies for the delay in actioning it.

@github-actions

Copy link
Copy Markdown
Contributor

Reminder, please take a look at this pr: @jrmccluskey

@github-actions

Copy link
Copy Markdown
Contributor

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @lostluck for label go.

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)

@github-actions

Copy link
Copy Markdown
Contributor

Reminder, please take a look at this pr: @lostluck

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @shunping for label go.

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)

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Reminder, please take a look at this pr: @shunping

@github-actions

Copy link
Copy Markdown
Contributor

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @lostluck for label go.

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)

@damccorm

Copy link
Copy Markdown
Contributor

@jrmccluskey could you take another look at this one?

@jrmccluskey

Copy link
Copy Markdown
Contributor

I don't know how I missed the follow-up ping, let me trigger the checks and we can get this moving

@jrmccluskey

Copy link
Copy Markdown
Contributor

Thank you for your patience!

@jrmccluskey
jrmccluskey merged commit 22ac580 into apache:master Jun 12, 2026
8 checks passed
ash6898 pushed a commit to ash6898/beam that referenced this pull request Jun 29, 2026
…mes (apache#38099)

* fix GCS filesystem glob matching to handle / in object names and support **

* update CHANGES.md

* update CHANGES.md

* address comments

* Update sdks/go/pkg/beam/io/filesystem/gcs/gcs.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* modify beam_PostCommit_Go.json as required

---------

Co-authored-by: corda.ilaria@gmail.com <ilariac691@gmail.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Jack McCluskey <34928439+jrmccluskey@users.noreply.github.com>
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.

[Go SDK] fileio.MatchAll() cannot match all files on GCS

4 participants