-
Notifications
You must be signed in to change notification settings - Fork 528
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
Fix: Check if bundle resource type is valid #3715
base: main
Are you sure you want to change the base?
Conversation
...lth.Fhir.Shared.Api/Features/Filters/FhirRequestContextRouteDataPopulatingFilterAttribute.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/BundleTransactionTests.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/BundleTransactionTests.cs
Fixed
Show fixed
Hide fixed
src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/Bundle/BundleHandler.cs
Fixed
Show fixed
Hide fixed
@@ -195,5 +199,16 @@ public void CheckElementsParameter(HttpContext httpContext) | |||
throw new BadRequestException(string.Format(Api.Resources.InvalidElementsParameter, elementsParameterValue)); | |||
} | |||
} | |||
|
|||
public void CheckIfBundleTypeIsInvalid(HttpContext httpContext) |
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.
Let me know if this check should be in a different place.
fhirRequestContext.BundleIssues.Add(new OperationOutcomeIssue( | ||
OperationOutcomeConstants.IssueSeverity.Error, | ||
OperationOutcomeConstants.IssueType.Exception, | ||
ex.Message)); |
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.
Since this isn't a recoverable error I don't think this belongs here. BundleIssues are mainly used for reporting issues during Search requests.
...why not just throw BadRequestException here?
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.
For some reason if I throw a BadRequest, it does return a 500 error instead of 400 as we want, so I added this as a work around but open to feedback, I will ask Fernando since he has more context!
fc66020
to
45b68e4
Compare
45b68e4
to
3e4b22d
Compare
Bug
When a customer sends a bundle with invalid "type", currently, we receive a 500 Internal Server Error which is incorrect.
Description
Adds validation and return BadRequest when an invalid "type" is received.
Related issues
Addresses [AB#114755].
Testing
FHIR Team Checklist
Semver Change (docs)
Patch|Skip|Feature|Breaking (reason)