diff --git a/src/Microsoft.Health.Fhir.Api/Resources.Designer.cs b/src/Microsoft.Health.Fhir.Api/Resources.Designer.cs index a28ccff42e..f0a3b70cd8 100644 --- a/src/Microsoft.Health.Fhir.Api/Resources.Designer.cs +++ b/src/Microsoft.Health.Fhir.Api/Resources.Designer.cs @@ -339,6 +339,15 @@ public static string InvalidBundleEntry { } } + /// + /// Looks up a localized string similar to Requested operation '{0}' is invalid using the request method {1}.. + /// + public static string InvalidBundleEntryRequest { + get { + return ResourceManager.GetString("InvalidBundleEntryRequest", resourceCulture); + } + } + /// /// Looks up a localized string similar to Bundle.entry.request.url is required.. /// diff --git a/src/Microsoft.Health.Fhir.Api/Resources.resx b/src/Microsoft.Health.Fhir.Api/Resources.resx index 649b8a5264..df433dbe17 100644 --- a/src/Microsoft.Health.Fhir.Api/Resources.resx +++ b/src/Microsoft.Health.Fhir.Api/Resources.resx @@ -426,4 +426,7 @@ inputParams not found, request body must be a valid Parameters resource. - \ No newline at end of file + + Requested operation '{0}' is invalid using the request method {1}. + + diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerTests.cs index 8d4fb9d672..f1604982b8 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerTests.cs @@ -371,6 +371,33 @@ public async Task GivenATransactionBundleRequestWithNullUrl_WhenProcessing_Retur await Assert.ThrowsAsync(async () => await _bundleHandler.Handle(bundleRequest, default)); } + [Fact] + public async Task GivenATransactionBundleRequestWithNullRequestMethod_WhenProcessing_ReturnsABadRequest() + { + var bundle = new Hl7.Fhir.Model.Bundle + { + Type = BundleType.Transaction, + Entry = new List + { + new EntryComponent + { + Request = new RequestComponent + { + Method = null, + Url = "/Patient", + }, + Resource = new Basic { Id = "test"}, + }, + }, + }; + + _router.When(r => r.RouteAsync(Arg.Any())) + .Do(RouteAsyncFunction); + + var bundleRequest = new BundleRequest(bundle.ToResourceElement()); + await Assert.ThrowsAsync(async () => await _bundleHandler.Handle(bundleRequest, default)); + } + [Fact] public async Task GivenABundle_WhenProcessed_CertainResponseHeadersArePropagatedToOuterResponse() { diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/Bundle/TransactionBundleValidator.cs b/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/Bundle/TransactionBundleValidator.cs index f4c7c261b4..4b053b1609 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/Bundle/TransactionBundleValidator.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/Bundle/TransactionBundleValidator.cs @@ -124,6 +124,12 @@ private async Task GetResourceId(EntryComponent entry, IDictionary