Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 887bbc7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
belaboe
left a comment
There was a problem hiding this comment.
Thanks. The fix is correct and matches index.aws.ts for all three cases, and the on-disk format is unchanged. One thing worth folding in: the non-versioned branch of the same get() (index.mock.ts:188) still throws EISDIR for get('docs') when docs/readme.txt exists (AWS returns null). The same isFile() guard plus one assert in the new test would cover it.
Non-blocking follow-ups:
- The mock doesn't validate
versionId:'readme.txt/v1'reads another key's v1, andrestoreVersionwith it leaves a phantom version. Reusing file-server's/^v\d+$/would close that. - The file-server GET has the same dir-vs-file gap.
- Nit: the changeset headline is broader than the fix, and DESIGN.md:24 "arbitrary keys ... matching S3" isn't true for
avsa/x.
…ck-phantom-versions # Conflicts: # packages/bb-file-bucket/src/index.mock.ts
…prefix of other keys
…ile-bucket-mock-phantom-versions
…another changeset
…ck-phantom-versions
|
Thanks! Folded in: |
Problem
The local
FileBucketmock stores version history for a key underversions/<key>/, so version history fordocs/readme.txtlives inversions/docs/readme.txt/. That makesversions/docs/contain a directory entry namedreadme.txt, which the mock treats as a version of the keydocs(packages/bb-file-bucket/src/index.mock.ts,listVersions):listVersions('docs')returns[{ versionId: 'readme.txt', isCurrent: true, ... }]althoughdocswas never written.get('docs', { versionId: 'readme.txt' })throwsEISDIRinstead of returningnull.restoreVersion('docs', 'readme.txt')passes the existence check and then throwsEISDIRfromreadFileSyncinstead ofVersionNotFound.Against AWS,
listVersions('docs')returns[](index.aws.tsskips listed versions whoseKeyis not the requested path), and the other two calls behave as for any unknown version.Issue #, if available:
Changes
packages/bb-file-bucket/src/index.mock.ts:listVersionsonly counts regular files as version entries. The versioned branch ofgetreturnsnullandrestoreVersionthrowsVersionNotFoundwhen the version path is not a regular file.packages/bb-file-bucket/src/index.test.ts: regression test for a key that is a prefix of another versioned key, with controls for the real key..changeset/bb-file-bucket-mock-phantom-versions.md: patch for@aws-blocks/bb-file-bucket.Validation
versioned: key that is a prefix of another key has no phantom versionsfailed before the fix (listVersions('docs')returned[{ versionId: 'readme.txt', isCurrent: true, ... }]instead of[]) and passes after it.npm run build,packages/bb-file-bucketnpm test(364 pass),npm run lint,npm run lint:deps: pass.npm test(all workspaces) andnpm run test:e2e:localfrom the repo root: pass.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.