return 404 errors when a file is not found in S3 #48
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.
When handling a
GET /public/file/{username}/{series}/{version}/{name}
request, Buildomat queries the database to determine the file path for the provided repo, series, version, and filename. If these queries don't find a file, the endpoint returns an HTTP 404 error. However, once the file path has been determined from the database, Buildomat will then attempt to find the actual file on the filesystem, or (if it isn't found locally) from S3. If the attempt to actually load the file from the local fs/S3 doesn't find a file, theCentral::file_response
method returns an error, which is always converted into an HTTP 500 response rather than a 404. It turns out that this case occurs when a build is in progress for a particular artifact, resulting in clients seeing 500 errors for nonexistent files.I've attempted to fix this issue by changing
Central::file_response
to return aResult<Option<FileResponse>>
rather than aResult<FileResponse>
. We now returnOk(None)
in cases where the file for the requested path doesn't exist on the local filesystem or in S3, and reserveErr
for cases where the file is present but we actually couldn't open it for whatever reason.Hopefully, this will result in 404s being returned for nonexistent files, rather than 500s. I wasn't sure how to verify that this completely resolves the issue, though --- any guidance would be very helpful. Thanks!