Handle an aws.ServeFile error gracefully instead of panicking - #427
Open
bauerpawel wants to merge 2 commits into
Open
bauerpawel wants to merge 2 commits into
bauerpawel wants to merge 2 commits into
Conversation
ServeFile previously called helper.Check(err) on the result of aws.ServeFile, which panics on any error (e.g. the object having gone missing from the bucket between metadata lookup and download). Log the error and write a plain error response instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0168YUwGEzEHTqd9CwzXE53d
forceDecryption=false made aws.ServeFile take the redirectToDownload path, which only presigns a URL without contacting S3, so it never returns an error for a missing object. Setting forceDecryption=true routes through serveDecryptedFile, which calls s3.GetObject directly and surfaces the missing-object error the test is meant to cover. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JWZJU5aSCEBB9DHBWvL4t4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ServeFilecalledhelper.Check(err)on the result ofaws.ServeFile, which panics on any error — for example if the object has gone missing from the bucket between the metadata lookup and the actual download, or any other transient S3-side failure. Logs the error and writes a plain error response to the client instead of crashing the request.Type of Change
Technical Details
How Has This Been Tested?
TestServeFileAwsErrorHandling, which registers a file with an AWS bucket set that was never actually uploaded (so the mock driver returns "file not found") and assertsServeFileresponds with the error message instead of panicking. Passes in isolation undergo test ./internal/storage/... --tags=test,awsmock -run TestServeFileAwsErrorHandling.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_0168YUwGEzEHTqd9CwzXE53d