Skip to content

Conversation

@mikaelweave
Copy link
Contributor

@mikaelweave mikaelweave commented Jan 23, 2026

Description

Adds RFC 6749/7662 compliant error handling for the Token Introspection endpoint by decoupling it from FHIR-specific exception handling.

AB#181870

Changes:

  • New OAuth2BadRequestException: Exception type for OAuth2 errors with error and error_descriptionproperties per RFC 6749
  • New OAuth2ExceptionFilterAttribute: Returns JSON error responses (not FHIR OperationOutcome) for OAuth2 endpoints
  • Content-Type validation: Validates application/x-www-form-urlencoded per RFC 7662 Section 2.1
  • Replaced filter: Changed from OperationOutcomeExceptionFilterAttribute to OAuth2ExceptionFilterAttribute

Why this change?

OAuth2 endpoints must return RFC 6749 error format ({"error": "...", "error_description": "..."}), not FHIR OperationOutcome responses. The TokenIntrospectionController was incorrectly using FHIR error handling.

Alternatives Considered

Related issues

Ensures token introspection endpoint returns spec-compliant error responses.

Testing

  • Unit tests for OAuth2ExceptionFilterAttribute
  • Updated TokenIntrospectionControllerTests for exception-based validation

@mikaelweave mikaelweave requested a review from a team as a code owner January 23, 2026 21:18
@mikaelweave mikaelweave added this to the FY26\Q3\2Wk\2Wk15 milestone Jan 23, 2026
@mikaelweave mikaelweave added Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs No-ADR ADR not needed No-PaaS-breaking-change and removed Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs labels Jan 23, 2026
- Added OAuth2BadRequestException for handling bad request errors.
- Introduced OAuth2ExceptionFilterAttribute to return RFC 6749 compliant error responses.
- Updated TokenIntrospectionController to validate content type and token presence.
- Enhanced TokenIntrospectionControllerTests to cover new validation scenarios.
- Added documentation for token introspection examples.
@mikaelweave mikaelweave changed the title Add support for UnsupportedMediaType error handling in FhirController Add RFC-compliant error handling for TokenIntrospectionController Jan 28, 2026
@mikaelweave mikaelweave added Azure API for FHIR Label denotes that the issue or PR is relevant to the Azure API for FHIR Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Area-SMART Bug Bug bug bug. labels Jan 28, 2026
@mikaelweave
Copy link
Contributor Author

@copilot can you address the PR comments from rbans96 and add any strings in the resource files as needed?

Copy link
Contributor

Copilot AI commented Jan 28, 2026

@mikaelweave I've opened a new pull request, #5357, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* Move error messages to Resources.resx for localization

Co-authored-by: mikaelweave <753437+mikaelweave@users.noreply.github.com>

* Add periods to error messages for consistency

Co-authored-by: mikaelweave <753437+mikaelweave@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mikaelweave <753437+mikaelweave@users.noreply.github.com>
@mikaelweave mikaelweave merged commit 221702a into main Jan 28, 2026
61 checks passed
@mikaelweave mikaelweave deleted the personal/mikaelw/fix-415-error-handling branch January 28, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-SMART Azure API for FHIR Label denotes that the issue or PR is relevant to the Azure API for FHIR Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Bug Bug bug bug. No-ADR ADR not needed No-PaaS-breaking-change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants