Repository navigation
fix(oss): return 404 when a file's stored data is missing - #7891
Open
shu-chen-dot-ca wants to merge 1 commit into
Open
shu-chen-dot-ca wants to merge 1 commit into
shu-chen-dot-ca wants to merge 1 commit into
Conversation
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.
Fixes #7356
When a
filerow still exists but its PostgreSQL large object is gone,lo_getfails with SQLSTATE 42704 and/oss/file/<id>answered{"code": 500, "message": "large object N does not exist"}(with HTTP 200).FileSerializer.Operate.get()now catches that one error and raises the sameNotFound404(404, 'File not found')already used when the row itself is missing. Any otherDatabaseErroris re-raised unchanged. No new translation string is needed.Tested on a local v2 setup (PostgreSQL 17 + pgvector, Redis): I uploaded a file, ran
lo_unlinkon its loid (the steps in the issue), then requested the file:/admin/oss/file/<id>and/chat/oss/file/<id>now return HTTP 404 "File not found" (before: code 500 with the raw database message).mp3file requested with aRangeheader gets the same 404ruff check apps/oss/serializers/file.pyandtypos apps/osspass