Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(http, server): handle missing resources with http 404 #367

Merged
merged 9 commits into from
Jan 12, 2024

Conversation

Aareksio
Copy link
Contributor

@Aareksio Aareksio commented Jan 6, 2024

πŸ”— Linked issue

unjs/ipx#204

Screenshot 2024-01-06 at 13 31 47

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

HTTP driver did not properly return null when resource was not found. The error was masked by createStorageServer newer throwing 404 as actual HTTP server should. This PR makes the createStorageServer return 404 and http driver to properly catch 404 and return null.

I have ran the changes against #365 and the behavior stays the same.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Copy link

codecov bot commented Jan 12, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (fc9f6a9) 63.92% compared to head (691d13a) 64.06%.

Files Patch % Lines
src/drivers/http.ts 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #367      +/-   ##
==========================================
+ Coverage   63.92%   64.06%   +0.14%     
==========================================
  Files          41       41              
  Lines        4102     4121      +19     
  Branches      489      493       +4     
==========================================
+ Hits         2622     2640      +18     
- Misses       1468     1469       +1     
  Partials       12       12              

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@pi0 pi0 changed the title fix(http): handle missing resources (http 404) fix(http, server): handle missing resources with http 404 Jan 12, 2024
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Small behavior changes to be documented in release notes:

  • HTTP server throws 404 for uneset values. This requires unstorage clients to update to the latest version to support handling
  • HTTP driver throws error for hasItem when response is not 404 (previously always returning null)

@pi0 pi0 merged commit 78e1568 into unjs:main Jan 12, 2024
4 of 5 checks passed
src/drivers/http.ts Outdated Show resolved Hide resolved
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