Skip to content

fix(gcs): preserve prefixes when listing with matchGlob - #188

Open
electrum wants to merge 1 commit into
floci-io:mainfrom
electrum:user/electrum/gcs-list-match-glob-prefixes
Open

fix(gcs): preserve prefixes when listing with matchGlob#188
electrum wants to merge 1 commit into
floci-io:mainfrom
electrum:user/electrum/gcs-list-match-glob-prefixes

Conversation

@electrum

@electrum electrum commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Preserves matching directory prefixes when objects.list combines delimiter=/ with matchGlob.

Type of change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change (feat!: or fix!:)
  • Docs / chore

GCP Compatibility

The behavior was reproduced in real GCS with objects under two prefixes:

$ gcloud storage cp /dev/null gs://$BUCKET/level0/file
Copying file:///dev/null to gs://$BUCKET/level0/file
$ gcloud storage cp /dev/null gs://$BUCKET/other/file
Copying file:///dev/null to gs://$BUCKET/other/file
$ curl --include --get \
    --header "Authorization: Bearer $(gcloud auth print-access-token)" \
    --data-urlencode 'delimiter=/' \
    --data-urlencode 'matchGlob=*/' \
    "https://storage.googleapis.com/storage/v1/b/$BUCKET/o"
HTTP/2 200
content-type: application/json; charset=UTF-8

{
  "kind": "storage#objects",
  "prefixes": [
    "level0/",
    "other/"
  ]
}

Floci previously returned only {"kind":"storage#objects"} for the same request. Real GCS was also checked for literal directory prefixes: a/* returns direct objects under a/, while a/** additionally returns matching nested prefixes. Backslash escaping was checked as well: a\b/* matches ab/file.txt, while a\\b/* matches an object named a\b/file.txt.

Checklist

  • ./mvnw test passes locally
  • New or updated integration test added
  • Commit messages follow Conventional Commits

@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown

Greptile Summary

This PR corrects GCS JSON object listings that combine delimiter and matchGlob.

  • Derives a fixed directory prefix before delimiter roll-up.
  • Applies glob matching to both retained objects and generated prefixes.
  • Aligns backslash handling between glob compilation and prefix extraction.
  • Adds REST integration and Java SDK compatibility coverage.

Confidence Score: 5/5

The PR appears safe to merge, with the previous backslash-prefix defect fully addressed and no new actionable issues identified.

Glob compilation and fixed-prefix extraction now share the same backslash semantics, while delimiter roll-up applies matching to both objects and generated prefixes under the existing request-level work bound.

Important Files Changed

Filename Overview
src/main/java/io/floci/gcp/services/gcs/GcsObjectController.java Moves glob filtering after delimiter roll-up so generated prefixes and retained objects are filtered consistently.
src/main/java/io/floci/gcp/services/gcs/GcsObjectGlob.java Adds fixed-directory-prefix extraction and makes glob compilation use the same backslash escape semantics.
src/test/java/io/floci/gcp/services/gcs/GcsListFilterRestIntegrationTest.java Covers prefix matching, literal directory prefixes, recursive globs, and backslash behavior through the REST API.
compatibility-tests/sdk-test-java/src/test/java/io/floci/gcp/test/GcsListFiltersTest.java Adds SDK-level verification that current-directory glob listings return matching prefixes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Bucket objects] --> B[Apply offsets and fixed listing prefix]
  B --> C[Roll up names using delimiter]
  C --> D[Retained object items]
  C --> E[Generated prefixes]
  D --> F[Apply matchGlob]
  E --> G[Apply matchGlob]
  F --> H[Paginate items]
  G --> I[Return matching prefixes]
  H --> J[GCS-compatible list response]
  I --> J
Loading

Reviews (2): Last reviewed commit: "fix(gcs): preserve prefixes when listing..." | Re-trigger Greptile

Comment thread src/main/java/io/floci/gcp/services/gcs/GcsObjectGlob.java
@electrum
electrum force-pushed the user/electrum/gcs-list-match-glob-prefixes branch from 330f02c to 797994e Compare September 9, 2026 05:06
@hectorvent hectorvent added bug Something isn't working storage Cloud Storage (GCS) labels Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working storage Cloud Storage (GCS)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants