* s3api: list object metadata with ListObjectsV2 metadata=true
A client that needs the type or user metadata of the objects it lists has
to HEAD each key. MinIO answers ListObjectsV2 with metadata=true by adding
each object's metadata to the page as <UserMetadata>, one element per
field, and its clients ask for it: minio-go ListObjectsOptions.WithMetadata,
minio-java ListObjectsArgs.includeUserMetadata, minio-py
list_objects(include_user_meta=True), and mc find --metadata.
With metadata=true each listed object carries the Content-Type and the
x-amz-meta-* fields GET and HEAD send for it, keyed as MinIO keys them
(content-type, X-Amz-Meta-Name). A symlink made through a mount lists with
inode/symlink and X-Amz-Meta-Seaweedfs-Symlink-Target, so links can be told
apart in a listing without a HEAD per key. As in MinIO, a key's metadata is
listed only for a caller allowed to read that key, through the per-key
check CopyObject uses for its source, so a List grant alone shows no more
than before and an anonymous caller gets none. Without the parameter, and
on ListObjects V1, nothing changes. HEAD and the listing share one
Content-Type rule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: hide listed metadata a tag-conditioned policy denies
GET decides the bucket policy again on the object's entry, so a Deny on
s3:ExistingObjectTag refuses the read. The metadata=true listing only ran
the key check, which sees no tags, and listed the metadata of an object
GET refuses. Decide it on the listed entry too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: keep setResponseHeaders' doc comment on it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: list a versioned object's metadata from its version file
The pointer cached on a .versions folder keeps an object's size, mtime,
ETag, owner and storage class, but not its type, user metadata or tags.
A metadata=true listing built from it showed a content type guessed from
the name and no x-amz-meta-* fields, and decided tag-conditioned policies
without the version's tags. Such a listing now reads the current
version's file, as GET and HEAD do; other listings keep using the pointer.
Reading the file also needed its path fixed: the fallback looked for it
under "<key>/.versions/", while versions live in "<key>.versions/", so a
pointer without the cached fields dropped the object from a listing or
failed it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: fold latestVersionEntryFromDirectoryEntry into getLatestVersionEntryFromDirectoryEntry
Every caller passes useCached, so the flag goes on the existing name
rather than a second function beside it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: fail a listing on a version file that cannot be read
With metadata=true every versioned key reads its version file in the
walk's .versions branch, which skipped the key on any error. A failed
read then answered a page that silently lacked the key, and a client
paging on could step past it. Skip only a version file that is gone, as
settlePendingNull and the version resolution do, and fail the listing on
any other error so the client retries it. The fallback now wraps the
lookup error with %w, so a removed version file still reads as not found
there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: list the remaining version when the pointer names a removed file
A .versions pointer can name a version file that has since been removed,
as when a delete lands while a listing reads it; with metadata=true every
versioned key reads its file. GET rescans .versions/ and self-heals the
pointer, but the listing skipped the key, which left a null object listed
just before its .versions sibling as the key's current version even when
a newer version remains. The listing now recovers read-only by the
rescan it already uses for a missing pointer: it lists the version that
remains, or the null object when that is newer. When nothing current
remains, it retracts a null object listed just before the folder, as
settlePendingNull does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: fail a listing when the null object cannot be read
The listing's .versions rescan treated any failed read of the base-path
null object as its absence. When that read failed for a moment and the
scan found no versions, the walk retracted the null object it had just
listed and answered success, paging past a key that still exists. The
rescan now returns such a read error, which fails the listing as an
unreadable version file already does; only a genuine not-found counts
as no null object.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: keep a directory from standing in for the null object in a listing rescan
The listing's .versions rescan read the base path and took whatever it
found as the null object. When the base path is a bare directory that
holds child keys, a directory newer than the remaining version replaced
it, and the listing dropped the key although GET answers that version.
The rescan now admits the base entry only when isNullVersionObject
accepts it, as GET's recoverLatestVersionWithoutPointer does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
see https://blog.aqwari.net/xml-schema-go/
1. go get aqwari.net/xml/cmd/xsdgen
2. Add EncodingType element for ListBucketResult in AmazonS3.xsd
3. xsdgen -o s3api_xsd_generated.go -pkg s3api AmazonS3.xsd
4. Remove empty Grantee struct in s3api_xsd_generated.go
5. Remove xmlns: sed s'/http:\/\/s3.amazonaws.com\/doc\/2006-03-01\/\ //' s3api_xsd_generated.go