Skip to content

fix: exact match should check key as path segment#65

Merged
jackieli-tes merged 2 commits intomainfrom
fix/exact-matching
Mar 11, 2026
Merged

fix: exact match should check key as path segment#65
jackieli-tes merged 2 commits intomainfrom
fix/exact-matching

Conversation

@jackieli-tes
Copy link
Contributor

Summary

  • Fixes exact matching in findObject — uses startsWith(key + "/") instead of startsWith(key) to ensure the cache key matches as a full path segment, not just a string prefix
  • Addresses the same issue as fix: exact matching #60 but with a correct fix (PR fix: exact matching #60's startsWith(key) still has the prefix-matching bug)
  • Adds a CI workflow test that saves a decoy cache with a longer key sharing the same prefix, then verifies exact restore does not match it

Context

Objects are stored as {key}/{cacheFileName} (e.g. my-cache/cache.tzst). MinIO's listObjectsV2 returns all objects with a matching string prefix, so querying my-cache also returns my-cache-v2/cache.tzst. Checking startsWith(key + "/") ensures only objects under the exact key directory match.

Test plan

  • test-exact-match workflow passes — decoy cache is not matched by exact restore
  • Existing test, test-env, lookup-only workflows still pass
  • build workflow confirms dist/ is up to date

listObjects uses MinIO prefix matching, so key "foo" also returns
"foo-bar/cache.tzst". The previous fix (PR #60) used startsWith(key)
which still has the same problem. Use startsWith(key + "/") to ensure
the key matches as a full path segment.

Add a workflow test that saves a decoy cache with a longer key sharing
the same prefix, then verifies exact restore does not match it.
On Windows, path.join produces backslash separators, so MinIO objects
have "\" in their names. The exact match check must use path.sep to
match the platform's separator.
@jackieli-tes jackieli-tes merged commit 47b4210 into main Mar 11, 2026
36 checks passed
@jackieli-tes jackieli-tes mentioned this pull request Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant