diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_2_0/3980-default-regression-bulk-job.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_2_0/3980-default-regression-bulk-job.yaml new file mode 100644 index 00000000000..2f81a0a2186 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_2_0/3980-default-regression-bulk-job.yaml @@ -0,0 +1,6 @@ +--- +type: fix +issue: 3980 +jira: SMILE-5053 +title: "A regression was introduced in 6.1.0 which caused bulk export jobs to not default to the correct output format when the `_outputFormat` parameter was omitted. +This behaviour has been fixed, and if omitted, will now default to the only legal value `application/fhir+ndjson`." diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportProviderTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportProviderTest.java index 7f39e0634d8..0cb75c6401f 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportProviderTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportProviderTest.java @@ -175,6 +175,28 @@ public class BulkDataExportProviderTest { assertTrue(params.getFilters().contains(filter)); } + @Test + public void testOmittingOutputFormatDefaultsToNdjson() throws IOException { + when(myJobRunner.startNewJob(any())) + .thenReturn(createJobStartResponse()); + + InstantType now = InstantType.now(); + + Parameters input = new Parameters(); + HttpPost post = new HttpPost("http://localhost:" + myPort + "/" + JpaConstants.OPERATION_EXPORT); + post.addHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_RESPOND_ASYNC); + post.setEntity(new ResourceEntity(myCtx, input)); + + try (CloseableHttpResponse response = myClient.execute(post)) { + assertEquals(202, response.getStatusLine().getStatusCode()); + } + + BulkExportParameters params = verifyJobStart(); + assertEquals(Constants.CT_FHIR_NDJSON, params.getOutputFormat()); + + + } + @Test public void testSuccessfulInitiateBulkRequest_Get() throws IOException { when(myJobRunner.startNewJob(any())).thenReturn(createJobStartResponse()); diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/bulk/export/provider/BulkDataExportProvider.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/bulk/export/provider/BulkDataExportProvider.java index 7e866e77f80..11240da0682 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/bulk/export/provider/BulkDataExportProvider.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/bulk/export/provider/BulkDataExportProvider.java @@ -365,7 +365,7 @@ public class BulkDataExportProvider { } private BulkDataExportOptions buildBulkDataExportOptions(IPrimitiveType theOutputFormat, IPrimitiveType theType, IPrimitiveType theSince, List> theTypeFilter, BulkDataExportOptions.ExportStyle theExportStyle) { - String outputFormat = theOutputFormat != null ? theOutputFormat.getValueAsString() : null; + String outputFormat = theOutputFormat != null ? theOutputFormat.getValueAsString() : Constants.CT_FHIR_NDJSON; Set resourceTypes = null; if (theType != null) {