-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Remove res.status calculation as it is set later #19214
Remove res.status calculation as it is set later #19214
Conversation
🦋 Changeset detectedLatest commit: ecb425e The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Actually, it is better to say that status is overridden later in the flow, so this removed logic, is actually just useless. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no guarantee that errors[0].status
is 500, so this will break the http error status code in case an error is thrown with a non-500 error code (like ForbiddenException) right?
No, but then errors.length is at least 1 so then the logic that follows will execute which if it isn't a DirectusError will set the status accordingly. |
Ahh right right, I wasn't looking further than the diff that github presented ^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original intended behavior was to use the err.status as the status code if it existed, or fall back to 500 if multiple errors of different types are thrown or if a non-directus error is thrown. That wasn't working as intended before either, but lets make that work as part of this PR. Small tweak incoming!
* Remove res.status calculation as it is set later * Ensure 500 is thrown on multiple errors of different types * Add changeset --------- Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
* Remove res.status calculation as it is set later * Ensure 500 is thrown on multiple errors of different types * Add changeset --------- Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
res.status is anyways set in either flow later in this function, so no need to loop through errors just for this.
Only edge case is when there are no errors, which would anyways just mean 500 as you can see.