Skip to content

fix: 404 for missing entries/groups/icons, repair icon caching headers#299

Open
allamiro wants to merge 1 commit into
lixmal:masterfrom
allamiro:fix/not-found-handling
Open

fix: 404 for missing entries/groups/icons, repair icon caching headers#299
allamiro wants to merge 1 commit into
lixmal:masterfrom
allamiro:fix/not-found-handling

Conversation

@allamiro

@allamiro allamiro commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #281, fixes #282.

Problem

Changes

  • new NotFoundError type in keepass.rs; lookups return it and handlers map it to 404 via a shared error_response() helper (resolves the existing 'Serve 404 if icon not found' TODO)
  • icon Cache-Control fixed: public, max-age=31536000, s-maxage=31536000, immutable
  • icon content type sniffed from magic bytes (PNG/JPEG/GIF/SVG, falling back to PNG — the previous behavior — for unknown data), resolving the 'sniff content type' TODO
  • unit tests for the 404 mapping and mime sniffing

Testing

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.

  • Bug Fixes
    • Added NotFoundError and a shared error_response to map not-found cases to 404.
    • Updated get_group_entries, get_entry, get_protected, and get_icon to use the new mapping.
    • Corrected icon Cache-Control to "public, max-age=31536000, s-maxage=31536000, immutable".
    • Sniff icon MIME type (PNG/JPEG/GIF/SVG) with PNG fallback; added tests for 404 mapping and MIME detection.

Written for commit fe86142. Summary will update on new commits.

Review in cubic

… 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
@allamiro allamiro force-pushed the fix/not-found-handling branch from fe86142 to db7e19c Compare June 13, 2026 00:17
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.

Entry/group 'not found' returns 500 instead of 404 Icon endpoint: malformed Cache-Control, wrong status for missing icons, hardcoded PNG

1 participant