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: 1414
>>
Background:
6
* url baseUrl
0
21:55:16.816 baseUrl: https://hapi.fhir.org/baseR4
21:55:16.816 fhirVersion: 4.0.1
9
Given path 'Patient'
0
10
And request {}
1
11
And header Content-Type = 'application/fhir+json'
0
12
When method post
1412
21:55:16.819 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
{}
21:55:18.229 response time in milliseconds: 1410
1 < 400
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Tue, 21 Apr 2026 21:55:18 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: MeLv86RofSqCOf1p
{
"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'
0
Scenario: [2:17]
TC-OO-002 OperationOutcome issue array is present and non-empty
ms: 3397
>>
Background:
6
* url baseUrl
0
21:55:16.834 baseUrl: https://hapi.fhir.org/baseR4
21:55:16.834 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
3395
21:55:16.839 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
{}
21:55:20.230 response time in milliseconds: 3391
1 < 400
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Tue, 21 Apr 2026 21:55:20 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: B1sj0tfQ2bvq1jpj
{
"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]'
1
Scenario: [3:25]
TC-OO-003 OperationOutcome issue severity is a valid value set member
ms: 4308
>>
Background:
6
* url baseUrl
0
21:55:16.918 baseUrl: https://hapi.fhir.org/baseR4
21:55:16.918 fhirVersion: 4.0.1
26
Given path 'Patient'
2
27
And request {}
0
28
And header Content-Type = 'application/fhir+json'
0
29
When method post
4305
21:55:16.922 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
{}
21:55:21.225 response time in milliseconds: 4303
1 < 400
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Tue, 21 Apr 2026 21:55:21 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: mWokpiXSQtyhOVVv
{
"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: 4997
>>
Background:
6
* url baseUrl
0
21:55:17.234 baseUrl: https://hapi.fhir.org/baseR4
21:55:17.234 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
4996
21:55:17.236 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
{}
21:55:22.230 response time in milliseconds: 4993
1 < 400
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Tue, 21 Apr 2026 21:55:22 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: dE7WtnNBGHoHtjl4
{
"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: 4995
>>
Background:
6
* url baseUrl
0
21:55:18.233 baseUrl: https://hapi.fhir.org/baseR4
21:55:18.233 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
4992
21:55:18.234 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
{}
21:55:23.226 response time in milliseconds: 4991
1 < 400
1 < Server: nginx/1.24.0 (Ubuntu)
1 < Date: Tue, 21 Apr 2026 21:55:23 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: TIqziLWRmvTMmHrO
{
"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
21:55:23.229 write to file: target/responses/operation-outcome-1776808523227.json