Skip to content

Gracefully handle OSErrors in StaticFiles#2222

Closed
etr2460 wants to merge 5 commits intoKludex:masterfrom
etr2460:patch-1
Closed

Gracefully handle OSErrors in StaticFiles#2222
etr2460 wants to merge 5 commits intoKludex:masterfrom
etr2460:patch-1

Conversation

@etr2460
Copy link
Copy Markdown

@etr2460 etr2460 commented Jul 21, 2023

Summary

Instead of reraising the OSError, handle it and raise an HTTPException with a Bad Request status code response. Arguably this could be a 404 to avoid leaking anything, but a 400 seemed reasonable (and better than not catching the error).

Implements solution 1 to the discussion here: #2221

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@Kludex
Copy link
Copy Markdown
Owner

Kludex commented Jul 22, 2023

@etr2460 Thanks for the PR.

Given what I replied on #2221 (comment), I'll be closing this.

@Kludex Kludex closed this Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants