You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: include errorCode in authorization exceptions - #28
Thanks for the PR! Closing, though: errorCode here only repeats the status code. unauthenticated is always 401 and forbidden is always 403, and GraphQL already exposes the same thing as extensions.code. Adding the field would also change every denial body (a breaking change for clients that match the exact body), and our 401s would no longer match the ones from the authentication guard.
A code would only help if it told apart denials that share a status, like which policy or ability denied. That's deliberately kept out of the response (it's on cause, for logs). If you need app-specific codes, an exception filter in your app can add them from cause.
Thanks! Yes I was aware that the errorCode repeats the current message, although in lowercase. My though was that authentication package does include error codes, it would make sense for consistency (at least some default value).
I started a new API recently with using Nest 12 and do take advantage error codes. I'll add an exception filter myself to include them.
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
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.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Authorization denial payloads omitted
errorCode.What is the new behavior?
Include the denial reason as
errorCodefor exceptions.Does this PR introduce a breaking change?