fix(oauth): use spec-compliant invalid_request error code (remove stray space)#12327
Merged
kojiromike merged 1 commit intoJun 1, 2026
Merged
Conversation
…tray space) `OAuthServerException` was constructed with the error code `'invalid _request'` (stray space), which is returned to clients verbatim in the JSON error response's `error` field. Per RFC 6749 §5.2 the OAuth2 error code is `invalid_request`. Replace all four occurrences in AuthorizationController.php and BearerTokenAuthorizationStrategy.php. Fixes openemr#12326 Assisted-By: Claude
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12327 +/- ##
============================================
- Coverage 25.80% 23.81% -2.00%
Complexity 84014 84014
============================================
Files 3910 3910
Lines 417451 417202 -249
============================================
- Hits 107707 99340 -8367
- Misses 309744 317862 +8118
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
kojiromike
approved these changes
Jun 1, 2026
This was referenced Jun 1, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Several
OAuthServerExceptionconstructions pass the error code'invalid _request'— with a stray space — instead of the spec value'invalid_request'. That value is echoed verbatim to clients in the JSON error response'serrorfield, so API consumers receive a non-standard OAuth2 error code:{"error":"invalid _request","error_description":"Invalid registration token"}Per RFC 6749 §5.2 the error code is
invalid_request(no space).Fix
Replace
'invalid _request'→'invalid_request'at all four occurrences:src/RestControllers/AuthorizationController.php— L496, L1458, L1484src/RestControllers/Authorization/BearerTokenAuthorizationStrategy.php— L177 (same typo; included for completeness)No behavioural change other than the corrected, spec-compliant error code.
Testing
Trigger any of the affected paths (e.g. an invalid dynamic-client-registration token, or a revoked refresh token) and confirm the JSON response now returns
"error":"invalid_request"instead of"error":"invalid _request".Fixes #12326