Skip to content

Replace 404 response with 403 and 500 when appropriate#18

Merged
hueniverse merged 1 commit intohapijs:masterfrom
kanongil:open-error-details
Jan 21, 2015
Merged

Replace 404 response with 403 and 500 when appropriate#18
hueniverse merged 1 commit intohapijs:masterfrom
kanongil:open-error-details

Conversation

@kanongil
Copy link
Copy Markdown
Contributor

This fixes a somewhat serious issue where clients would get a 404 responses when open fails because of EMFILE, etc. This should not happen for this kind of ephemeral error.

The patch will now only return 404 when the filesystem reports ENOENT. Otherwise, it will detect permission errors and return 403 responses to indicate this, and finally it can fail with an internal error, exposing the actual error.

@kanongil kanongil added the bug Bug or defect label Jan 16, 2015
lib/file.js Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need for else.
Is the | a typo for ||?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I used a single | to retain code coverage. The new tests will trigger EACCES on linux but on windows EPERM is triggered instead. Afaik both values indicate a permission issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ugh. you should find another way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, I fixed it with additional mocking. I suspect a more proper solution would be to write a new module that converts syserr to Boom errors and use that instead. Any thoughts on such a module @arb ?

@hueniverse hueniverse self-assigned this Jan 16, 2015
@hueniverse hueniverse added this to the 2.1.1 milestone Jan 21, 2015
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Style nit: Capitalize failed, also line 205 missing space after function

hueniverse pushed a commit that referenced this pull request Jan 21, 2015
Replace 404 response with 403 and 500 when appropriate
@hueniverse hueniverse merged commit b6c935b into hapijs:master Jan 21, 2015
@lock
Copy link
Copy Markdown

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Bug or defect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants