Summary|
Tags|
Feature:
common/operation-outcome.feature|
OperationOutcome Validation
Tests that the HAPI FHIR sandbox returns well-formed OperationOutcome
resources for invalid requests, per REQ-ERR-001 through REQ-ERR-004.
Scenario: [1:8]
TC-OO-001 OperationOutcome returned for invalid resource POST
ms: 1648
>>
Background:
6
* url baseUrl
0
03:39:57.706 baseUrl: https://hapi.fhir.org/baseR4
03:39:57.707 fhirVersion: 4.0.1
9
Given path 'Patient'
0
10
And request {}
7
11
And header Content-Type = 'application/fhir+json'
0
12
When method post
1639
03:39:57.716 request:
1 > POST https://hapi.fhir.org/baseR4/Patient
1 > Content-Type: application/fhir+json; charset=UTF-8
1 > Content-Length: 2
1 > Host: hapi.fhir.org
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18)
1 > Accept-Encoding: gzip,deflate
{}
03:39:59.353 response time in milliseconds: 1636
1 < 400
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Thu, 16 Apr 2026 03:39:59 GMT
1 < Content-Type: application/fhir+json;charset=utf-8
1 < Transfer-Encoding: chunked
1 < Connection: keep-alive
1 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4)
1 < X-Request-ID: 7agZ95Ccy6QU0O55
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td>HAPI-0450: Failed to parse request body as JSON resource. Error was: HAPI-1838: Invalid JSON content detected, missing required element: 'resourceType'</td></tr></table></div>"
},
"issue": [ {
"severity": "error",
"code": "processing",
"diagnostics": "HAPI-0450: Failed to parse request body as JSON resource. Error was: HAPI-1838: Invalid JSON content detected, missing required element: 'resourceType'"
} ]
}
13
Then status 400
0
14
And assert responseTime < 10000
0
15
And match response.resourceType == 'OperationOutcome'
1
Scenario: [2:17]
TC-OO-002 OperationOutcome issue array is present and non-empty
ms: 2460
>>
Background:
6
* url baseUrl
0
03:39:57.894 baseUrl: https://hapi.fhir.org/baseR4
03:39:57.894 fhirVersion: 4.0.1
18
Given path 'Patient'
0
19
And request {}
0
20
And header Content-Type = 'application/fhir+json'
0
21
When method post
2458
03:39:57.896 request:
1 > POST https://hapi.fhir.org/baseR4/Patient
1 > Content-Type: application/fhir+json; charset=UTF-8
1 > Content-Length: 2
1 > Host: hapi.fhir.org
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18)
1 > Accept-Encoding: gzip,deflate
{}
03:40:00.353 response time in milliseconds: 2456
1 < 400
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Thu, 16 Apr 2026 03:40:00 GMT
1 < Content-Type: application/fhir+json;charset=utf-8
1 < Transfer-Encoding: chunked
1 < Connection: keep-alive
1 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4)
1 < X-Request-ID: E5ZPuVLg08o0dNjq
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td>HAPI-0450: Failed to parse request body as JSON resource. Error was: HAPI-1838: Invalid JSON content detected, missing required element: 'resourceType'</td></tr></table></div>"
},
"issue": [ {
"severity": "error",
"code": "processing",
"diagnostics": "HAPI-0450: Failed to parse request body as JSON resource. Error was: HAPI-1838: Invalid JSON content detected, missing required element: 'resourceType'"
} ]
}
22
Then status 400
0
23
And match response.issue == '#[_ > 0]'
2
Scenario: [3:25]
TC-OO-003 OperationOutcome issue severity is a valid value set member
ms: 4410
>>
Background:
6
* url baseUrl
0
03:39:57.943 baseUrl: https://hapi.fhir.org/baseR4
03:39:57.943 fhirVersion: 4.0.1
26
Given path 'Patient'
0
27
And request {}
0
28
And header Content-Type = 'application/fhir+json'
0
29
When method post
4409
03:39:57.945 request:
1 > POST https://hapi.fhir.org/baseR4/Patient
1 > Content-Type: application/fhir+json; charset=UTF-8
1 > Content-Length: 2
1 > Host: hapi.fhir.org
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18)
1 > Accept-Encoding: gzip,deflate
{}
03:40:02.352 response time in milliseconds: 4407
1 < 400
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Thu, 16 Apr 2026 03:40:02 GMT
1 < Content-Type: application/fhir+json;charset=utf-8
1 < Transfer-Encoding: chunked
1 < Connection: keep-alive
1 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4)
1 < X-Request-ID: LXOllh84ettRizO4
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td>HAPI-0450: Failed to parse request body as JSON resource. Error was: HAPI-1838: Invalid JSON content detected, missing required element: 'resourceType'</td></tr></table></div>"
},
"issue": [ {
"severity": "error",
"code": "processing",
"diagnostics": "HAPI-0450: Failed to parse request body as JSON resource. Error was: HAPI-1838: Invalid JSON content detected, missing required element: 'resourceType'"
} ]
}
30
Then status 400
0
31
And match each response.issue contains { severity: '#regex (fatal|error|warning|information)' }
1
Scenario: [4:33]
TC-OO-004 OperationOutcome issue code is present
ms: 4993
>>
Background:
6
* url baseUrl
0
03:39:58.362 baseUrl: https://hapi.fhir.org/baseR4
03:39:58.362 fhirVersion: 4.0.1
34
Given path 'Patient'
0
35
And request {}
0
36
And header Content-Type = 'application/fhir+json'
0
37
When method post
4992
03:39:58.364 request:
1 > POST https://hapi.fhir.org/baseR4/Patient
1 > Content-Type: application/fhir+json; charset=UTF-8
1 > Content-Length: 2
1 > Host: hapi.fhir.org
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18)
1 > Accept-Encoding: gzip,deflate
{}
03:40:03.354 response time in milliseconds: 4990
1 < 400
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Thu, 16 Apr 2026 03:40:03 GMT
1 < Content-Type: application/fhir+json;charset=utf-8
1 < Transfer-Encoding: chunked
1 < Connection: keep-alive
1 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4)
1 < X-Request-ID: 8n4Wzzz9WyNNiqGS
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td>HAPI-0450: Failed to parse request body as JSON resource. Error was: HAPI-1838: Invalid JSON content detected, missing required element: 'resourceType'</td></tr></table></div>"
},
"issue": [ {
"severity": "error",
"code": "processing",
"diagnostics": "HAPI-0450: Failed to parse request body as JSON resource. Error was: HAPI-1838: Invalid JSON content detected, missing required element: 'resourceType'"
} ]
}
38
Then status 400
0
39
And match each response.issue contains { code: '#present' }
1
Scenario: [5:41]
TC-OO-005 OperationOutcome captured to target/responses/
ms: 4996
>>
Background:
6
* url baseUrl
0
03:39:59.359 baseUrl: https://hapi.fhir.org/baseR4
03:39:59.359 fhirVersion: 4.0.1
42
Given path 'Patient'
0
43
And request {}
0
44
And header Content-Type = 'application/fhir+json'
0
45
When method post
4994
03:39:59.361 request:
1 > POST https://hapi.fhir.org/baseR4/Patient
1 > Content-Type: application/fhir+json; charset=UTF-8
1 > Content-Length: 2
1 > Host: hapi.fhir.org
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.18)
1 > Accept-Encoding: gzip,deflate
{}
03:40:04.353 response time in milliseconds: 4992
1 < 400
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Thu, 16 Apr 2026 03:40:04 GMT
1 < Content-Type: application/fhir+json;charset=utf-8
1 < Transfer-Encoding: chunked
1 < Connection: keep-alive
1 < X-Powered-By: HAPI FHIR 8.9.4-SNAPSHOT/eee190b153/2026-02-26 REST Server (FHIR Server; FHIR 4.0.1/R4)
1 < X-Request-ID: KVMqVvFECHU6Vnva
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td>HAPI-0450: Failed to parse request body as JSON resource. Error was: HAPI-1838: Invalid JSON content detected, missing required element: 'resourceType'</td></tr></table></div>"
},
"issue": [ {
"severity": "error",
"code": "processing",
"diagnostics": "HAPI-0450: Failed to parse request body as JSON resource. Error was: HAPI-1838: Invalid JSON content detected, missing required element: 'resourceType'"
} ]
}
46
Then status 400
0
47
* def fileName = 'operation-outcome-' + java.lang.System.currentTimeMillis() + '.json'
1
48
* karate.write(response, 'responses/' + fileName)
1
03:40:04.356 write to file: target/responses/operation-outcome-1776310804354.json