Skip to content

refactor(files_external/s3): tighten headObject error handling and normalization#58644

Open
joshtrichards wants to merge 2 commits intomasterfrom
jtr/refactor-external-s3-headObject
Open

refactor(files_external/s3): tighten headObject error handling and normalization#58644
joshtrichards wants to merge 2 commits intomasterfrom
jtr/refactor-external-s3-headObject

Conversation

@joshtrichards
Copy link
Member

@joshtrichards joshtrichards commented Feb 28, 2026

  • Resolves: #

Summary

  • Normalize Key only when writing to cache (once), not on subsequent reads.
  • Caches only explicit “not found” responses (404, NoSuchKey, NotFound) as false.
  • Rethrows unexpected client/server S3 errors instead of treating all non-5xx as missing.
  • Use an early return to reduce nesting and improve readability.

This reduces the risk of masking permission/configuration issues, avoids repeated normalization work, and improves code clarity.

TODO

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

- Refactor headObject() to use early-return on cache hit for readability
- Reduce code nesting
- Normalize S3 object metadata to include 'Key' when caching (once) versus when reading (always)
- Add explicit structured return type in docblock

No observable change in behavior; improves code clarity and consistently ensures normalized cache entries.

Signed-off-by: Josh <josh.t.richards@gmail.com>
- Classify explicit “missing object” conditions only (404, maybe NoSuchKey, NotFound) as negative cache.
- No longer swallow non-notfound 4xx (i.e. <500) by caching as false. Instead throw upstream (to expose authentication problems, etc.)


Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards added this to the Nextcloud 34 milestone Feb 28, 2026
@joshtrichards joshtrichards requested a review from a team as a code owner February 28, 2026 16:28
@joshtrichards joshtrichards removed the request for review from a team February 28, 2026 16:28
@joshtrichards joshtrichards added the 3. to review Waiting for reviews label Feb 28, 2026
@joshtrichards joshtrichards added feature: external storage feature: object storage ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) labels Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews enhancement feature: external storage feature: object storage ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant