fix: 404 for missing entries/groups/icons, repair icon caching headers#299
Open
allamiro wants to merge 1 commit into
Open
fix: 404 for missing entries/groups/icons, repair icon caching headers#299allamiro wants to merge 1 commit into
allamiro wants to merge 1 commit into
Conversation
… headers - NotFoundError type distinguishes missing kdbx objects from real server faults; affected handlers now return 404 instead of 500 - icon Cache-Control used semicolons and 's-max-age', which browsers ignore; now: public, max-age=31536000, s-maxage=31536000, immutable - icon content type is sniffed from magic bytes (png/jpeg/gif/svg) instead of always claiming image/png
fe86142 to
db7e19c
Compare
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 #281, fixes #282.
Problem
500 Internal Server Error, indistinguishable from real server faults (Entry/group 'not found' returns 500 instead of 404 #282)Cache-Control: max-age=31536000; public; s-max-age=31536000is invalid (semicolons instead of commas,s-max-ageinstead ofs-maxage) so browsers ignored it and re-fetched icons; content type was alwaysimage/pngregardless of the data (Icon endpoint: malformed Cache-Control, wrong status for missing icons, hardcoded PNG #281)Changes
NotFoundErrortype inkeepass.rs; lookups return it and handlers map it to 404 via a sharederror_response()helper (resolves the existing 'Serve 404 if icon not found' TODO)public, max-age=31536000, s-maxage=31536000, immutableTesting
cargo test: 11/11 pass (2 new) in a rust:1.83 container.Summary by cubic
Return 404 for missing entries, groups, protected fields, and icons instead of 500. Fix icon caching headers and MIME detection so browsers cache icons correctly. Fixes #281 and #282.
Written for commit fe86142. Summary will update on new commits.