Repository navigation
feat(snapshot s3)!: always report the bucket as the one artifact, and stop failing on an empty bucket - #1410
Conversation
A bucket holding one object was reported as an artifact named after that object, while a bucket holding several was reported as an artifact named after the bucket. Adding a second file to a bucket therefore renamed the artifact, and a one-object snapshot did not say which bucket it was taken from. The team decided that an S3 snapshot always reports the bucket as its one artifact. The fingerprint is calculated as before: a single object is still fingerprinted as that file, so it keeps matching an artifact attested with --artifact-type file. Only the name changes. BREAKING CHANGE: a snapshot of a bucket holding a single object now names its artifact after the bucket instead of after the object. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…sult The artifact is now always named after the bucket, which the caller already holds, so the fingerprint pipeline no longer needs to decide a name and hand it back. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ctory VirtualDirSha256 refused an empty file list, although DirSha256 accepts an empty directory and returns the sha256 of no input. An S3 bucket with nothing to fingerprint is about to be reported as an artifact rather than failing the snapshot, and its fingerprint should be the one `kosli fingerprint --artifact-type dir` gives for an empty directory, so the virtual calculation now agrees with the on-disk one for that case too. The value is pinned in the test because snapshots will carry it. Co-Authored-By: Claude Fable 5.2 <[email protected]>
A bucket that listed no objects, or only folder markers, failed the snapshot with "no matching file or dirs in bucket". When a bucket that was being snapshotted was emptied, every later snapshot failed, so Kosli kept showing the last content the bucket held and the loss of the files was never recorded. An empty bucket is a valid state, so it is now reported like any other: one artifact named after the bucket. Its fingerprint is that of an empty directory, the value `kosli fingerprint --artifact-type dir` gives for one, so the calculation is the one already used for a bucket with content. No object supplies a modification time, so the timestamp is 0, which keeps repeated snapshots of an empty bucket identical. A line on stdout says the bucket held no objects. A filter that leaves nothing still fails; that changes next. BREAKING CHANGE: snapshotting an S3 bucket that holds no objects now succeeds and reports the bucket as an empty artifact, where it used to exit with an error. Co-Authored-By: Claude Fable 5.2 <[email protected]>
When --include, --include-regex, --exclude or --exclude-regex left no object to fingerprint, the snapshot failed with "no matching file or dirs in bucket". The check dates from when the filters were added, on the reasoning that nothing left to report most likely meant a mistyped filter. The team decided that the filters define what the snapshot sees of the bucket, so a filtered view with nothing in it is reported the same way as a bucket with nothing in it: one artifact named after the bucket, with the empty-directory fingerprint. Failing instead would leave Kosli showing the content from the last successful snapshot after the matching objects had been removed. A mistyped filter is still a real risk, so this case logs a warning rather than the plain line an unfiltered empty bucket gets. BREAKING CHANGE: snapshotting an S3 bucket with include or exclude filters that match no object now succeeds, with a warning, and reports the bucket as an empty artifact, where it used to exit with an error. Co-Authored-By: Claude Fable 5.2 <[email protected]>
With --fingerprint-source metadata and --skip-unusable-checksums, a bucket in which no object had a usable SHA256 checksum was reported as a snapshot with no artifacts. That was the only case in which an S3 snapshot carried an empty artifact list, and it left nothing in the snapshot to say which bucket had been read. An S3 snapshot now always carries exactly one artifact, the bucket, so this case is reported like an empty bucket: named after the bucket, with the empty-directory fingerprint. The warning naming the skipped objects is unchanged. BREAKING CHANGE: with --skip-unusable-checksums, a bucket whose objects are all skipped is now reported as one artifact with the empty-directory fingerprint instead of as an empty artifact list. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The help text said only that the content is reported as one artifact, and that skipping every checksum gives an empty snapshot. Both are out of date now that the artifact is always named after the bucket and a bucket with nothing to report is an empty-directory artifact rather than an error or an empty list. The long description now states the name, which `kosli fingerprint` artifact type the fingerprint corresponds to, and what is reported when nothing is left, including the fingerprint value so it can be recognised in Kosli. The --skip-unusable-checksums flag text follows. The fingerprint ADR described the single-object artifact as named after the object; it gains a dated note recording what has changed rather than being rewritten, since the calculation it records stands. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…oke test No case in TestGetS3Data ever set wantArtifactName, so it always fell back to the bucket name. The artifact is now always named after the bucket, so the field and its fallback say nothing and are removed. The "includePaths is a file" case looked its fingerprint up under the bucket name while the artifact was named README.md, so it could not have passed against real AWS before the naming change. It is skipped without AWS credentials and has not been run here. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The command suite still expected --include matching nothing to fail, and the old wording for a bucket whose every checksum was skipped. Both now expect the bucket to be reported as empty, and an --exclude-regex that removes every object is covered alongside them. A new case snapshots a bucket holding only a folder marker, from both fingerprint sources. Because the suite reports to the local Kosli server, it also shows that the server accepts what an empty bucket is reported with: the empty-directory fingerprint and a timestamp of 0. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Claude finished @gsavage's task in 1m 34s —— View job Follow-up review complete ✅
Summary posted: #1410 (comment) The only Claude-raised finding (the Not run: |
…d the bucket The warning fires whenever a filter is set and no object is left, but that does not show the filters removed anything: the bucket may have been empty, or held only folder markers, before any filter ran. Saying "no object is left by the filters" then points someone debugging at their filters when the bucket itself is the cause. Reword the warning to say that no object matches the filters or the bucket is empty. Counting the objects seen before filtering would let the message be exact, but the reported snapshot is the same either way, so the wording change is enough. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
I've tested this locally, using an S3 bucket into which I placed files, emptied it, uploaded with and without SHA256. In all cases the result was as expected -- a single artifact reported, with the name of the S3 bucket and the fingerprint for the files that matched, or the fingerprint for an empty bucket as the case may be. |
| const snapshotS3LongDesc = snapshotS3ShortDesc + awsAuthDesc + ` | ||
| You can report the entire bucket content, or filter some of the content using ^--include^ / ^--exclude^ (literal prefix match) or ^--include-regex^ / ^--exclude-regex^ (Go regular expressions matched against the full object key). | ||
| In all cases, the content is reported as one artifact. If you wish to report separate files/dirs within the same bucket as separate artifacts, you need to run the command twice. | ||
| In all cases, the content is reported as one artifact, named after the bucket. If you wish to report separate files/dirs within the same bucket as separate artifacts, you need to run the command twice. |
There was a problem hiding this comment.
Both runs now produce an artefact with the same name, and the sentence does not say they need separate environments.
|
The change looks good and matches what was agreed. Just few minor observations:
Nits
|
… cases Every S3 snapshot now names its one artifact after the bucket, so the wantArtifactName field held the same value in every case of both TestPinnedFingerprints tables and told the reader nothing. Assert the bucket name directly instead, which leaves the fingerprint as the only thing each case pins. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The amendment note under Guarantees says a single object is now named after the bucket, but two other sentences in the record still described the artifact name as the object's basename without pointing at it. A reader landing on either one would take the old naming as current. Annotate both in place rather than rewrite them, so the record still shows what was decided at the time. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Follow-up review: commits 9c859ef..03db746 (since 6552b00)Scope: Prior findings:
Nits from the PR-body comment thread (mbevc1), now addressed by these commits:
New inline comments: 0. The touched hunks are mechanical (dropping a now-constant test field, clarifying ADR prose) and don't introduce any new bug, security issue, or regression. Note: |
|
We left |
|
Thanks @mbevc1. In reply to #1410 (comment):
Nits, both addressed: |
The long description told users to run the command twice to report separate files or dirs as separate artifacts. Since #1410 every S3 artifact is named after the bucket, and a snapshot replaces the environment's previous one, so two runs against one environment leave only the second. The text now says to run once per subset with --include, each against its own environment. Also reword the flags-auth example comment from "what is running in" a bucket to "the contents of" it, matching the other examples.
…1412) * docs(snapshot s3): say separate artifacts need separate environments The long description told users to run the command twice to report separate files or dirs as separate artifacts. Since #1410 every S3 artifact is named after the bucket, and a snapshot replaces the environment's previous one, so two runs against one environment leave only the second. The text now says to run once per subset with --include, each against its own environment. Also reword the flags-auth example comment from "what is running in" a bucket to "the contents of" it, matching the other examples. * docs(snapshot s3): shorten the separate-artifacts sentence The sentence named only --include, although --include-regex and the exclude filters can also split a bucket into subsets, and it ended by repeating that the artifact is named after the bucket. It now offers --include as an example and keeps only the reason that matters: a snapshot replaces the environment's previous one.
…567) ## When to merge This describes behaviour from kosli-dev/cli#1410, which is not released. However S3 snapshots are not enabled for any customers, so it is safe to merge this now. ## What Updates the "What to expect" list under *Capturing S3 buckets* in `administration/cloud_capture/getting_started.md`: - New: each bucket reports exactly one artifact, named after the bucket, including a bucket that holds a single object (previously named after the object). - New: an empty bucket is captured rather than failing, and reports the fingerprint of an empty directory (`e3b0c442…b855`). - Changed: a bucket where no object carries a SHA256 checksum is reported as an empty bucket, where the page said it "is reported as holding no artifact". ## Why Cloud Capture snapshots buckets with `kosli snapshot s3`, and kosli-dev/cli#1410 changes that command's default behaviour as agreed in kosli-dev/cloud-capture#216. ## Not included `client_reference/kosli_snapshot_s3.md` still carries the old wording. That page is generated from the CLI help text at release, so it is left for the release to regenerate. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.2 <[email protected]>
kosli snapshot s3now always reports exactly one artifact, named after the bucket, and a bucketwith nothing to fingerprint is no longer an error. This changes the default behaviour of the
command; it replaces the
--allow-empty-bucketflag from #1405, which was reverted in #1407.The approach was agreed by the team and is recorded in kosli-dev/cloud-capture#216.
Why
kept showing the last content the bucket held and the loss of the files was never recorded.
holding several was named after the bucket. Adding a second file renamed the artifact, and a
one-object snapshot did not say which bucket it came from.
What changes for users (breaking)
no matching file or dirs in bucket--include/--include-regex/--exclude/--exclude-regexleave nothing--skip-unusable-checksumsskips every object"Reported as an empty bucket" means one artifact named after the bucket, with:
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855, which is whatkosli fingerprint --artifact-type dirgives for an empty directory.creationTimestamp0, since no object supplies a modification time. A constant keepsrepeated snapshots of an empty bucket identical.
The fingerprint calculation for buckets with content is unchanged: a single object is still
fingerprinted as that file, and several as a directory.
Not changed: with
--fingerprint-source metadataand without--skip-unusable-checksums, anobject with no usable checksum still fails the snapshot.
Things for the reviewer to weigh
nothing log a
[warning], because a mistyped filter has the same effect and now no longer fails.digest.VirtualDirSha256accepts no files. It used to return an error; it now returns theempty-directory fingerprint, matching
DirSha256on an empty directory. The value is pinned in atest.
docs/adr/20260911-s3-fingerprint-from-virtual-tree.md) gains a dated note ratherthan being rewritten, since the calculation it records still stands.
Testing
go test --short ./...passes against the local Kosli server, including the S3 command suite.That suite confirms the server accepts the empty-directory fingerprint and a timestamp of 0.
make lintreports 0 issues.TestGetS3Data) is skipped without AWS credentials and was not run.Checklist
charts/k8s-reporter/) updated, if needed. Note: these changes live in a separate PRThe Helm chart does not snapshot S3. Whether
terraform-aws-kosli-reporterrelies on the oldbehaviour has not been checked.
🤖 Generated with Claude Code