Skip to content

Conversation

@Charles-Patrick-Moore
Copy link

@Charles-Patrick-Moore Charles-Patrick-Moore commented Jan 7, 2026

Description

PATCH requests without a Content-Type header or with an empty body cause an AmbiguousMatchException and return HTTP 500

Related issues

#5176

Testing

Passing Testing Checklist:

PATCH with empty body → HTTP 400 Bad Request

Error message indicates Content-Type and body are required

PATCH with Content-Type: application/json-patch+json + valid body → routes to PatchJson

PATCH with Content-Type: application/fhir+json + valid body → routes to PatchFhir

No AmbiguousMatchException in telemetry after deployment

E2E tests cover all scenarios

Integration tests verify routing and validation behavior.

##Everything works except:

*PATCH without Content-Type → HTTP 400 Bad Request

I tried all of the suggested methods, including a custom filter, but none passed this

FHIR Team Checklist

  • Update the title of the PR to be succinct and less than 65 characters
  • Add a milestone to the PR for the sprint that it is merged (i.e. add S47)
  • Tag the PR with the type of update: Bug, Build, Dependencies, Enhancement, New-Feature or Documentation
  • Tag the PR with Open source, Azure API for FHIR (CosmosDB or common code) or Azure Healthcare APIs (SQL or common code) to specify where this change is intended to be released.
  • Tag the PR with Schema Version backward compatible or Schema Version backward incompatible or Schema Version unchanged if this adds or updates Sql script which is/is not backward compatible with the code.
  • When changing or adding behavior, if your code modifies the system design or changes design assumptions, please create and include an ADR.
  • CI is green before merge Build Status
  • Review squash-merge requirements

Semver Change (docs)

Patch|Skip|Feature|Breaking (reason)

@Charles-Patrick-Moore Charles-Patrick-Moore requested a review from a team as a code owner January 7, 2026 00:01
@PTaladay
Copy link
Contributor

PTaladay commented Jan 8, 2026

@Charles-Patrick-Moore thanks for your submission. Can you add some tests that cover these changes into your pr please. Based on your description it sounds like you did some manual verification, but it would be best to have tests to cover this scenario to ensure we don't have regressions in the future. Thanks

@Charles-Patrick-Moore
Copy link
Author

@microsoft-github-policy-service agree

@Charles-Patrick-Moore
Copy link
Author

Added unit tests

@Charles-Patrick-Moore
Copy link
Author

Charles-Patrick-Moore commented Jan 9, 2026 via email

[Fact]
public async Task GivenPatchFhirRequestWithEmptyBody_WhenInvoked_ThenReturnsBadRequest()
{
var request = new HttpRequestMessage(HttpMethod.Patch, "Patient/example");

Check warning

Code scanning / CodeQL

Missing Dispose call on local IDisposable Warning test

Disposable 'HttpRequestMessage' is created but not disposed.
@PTaladay PTaladay changed the base branch from main to externalcontribution/Charles-Patrick-Moore/ambiguousmatchpatchexceptionfix January 9, 2026 20:22
@PTaladay PTaladay merged commit 0669d55 into microsoft:externalcontribution/Charles-Patrick-Moore/ambiguousmatchpatchexceptionfix Jan 9, 2026
4 of 5 checks passed
@Charles-Patrick-Moore Charles-Patrick-Moore deleted the Fix-5176-AmbiguousMatchException-PatchJson-PatchFhir-methods branch January 10, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants