Skip to content

Commit

Permalink
Fix: [AEA-4045] - PSU returning empty 200 response with header Conten…
Browse files Browse the repository at this point in the history
…t-Type set to application/fhir+json (#276)

## Summary

🎫 [AEA-4045](https://nhsd-jira.digital.nhs.uk/browse/AEA-4045) PSU
returning empty 200 response with header Content-Type set to
application/fhir+json

- 🤖 Operational or Infrastructure Change

### Details

PSU returning empty 200 response with header Content-Type set to
application/fhir+json.

- Expected Behaviour
The response is processed successfully (data added to dynamodb if all
items pass validation)
A 201 response is returned if all items pass validation
A 400 response is returned if items fail validation

- Observed Behaviour
A 200 response is returned with 3 empty lines if validation passes or
fails

---------

Co-authored-by: Anthony Brown <[email protected]>
  • Loading branch information
kris-szlapa and anthony-nhs authored Jun 6, 2024
1 parent 35cc0d2 commit abfde9f
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ sam-deploy-package: guard-artifact_bucket guard-artifact_bucket_prefix guard-sta
TruststoreVersion=$$LATEST_TRUSTSTORE_VERSION \
EnableMutualTLS=$$enable_mutual_tls \
EnableSplunk=true \
EnableDynamoDBAutoScaling=$$DYNAMODB_AUTOSCALE \
EnableDynamoDBAutoScaling=$$DYNAMODB_AUTOSCALE \
VersionNumber=$$VERSION_NUMBER \
CommitId=$$COMMIT_ID \
LogLevel=$$LOG_LEVEL \
Expand Down
68 changes: 66 additions & 2 deletions SAMtemplates/apis/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,70 @@ Resources:
"input": "{$util.escapeJavaScript($inputString.substring(1,$len))}"
}
- stateMachineArn: !Ref UpdatePrescriptionStatusStateMachineArn
application/fhir+json: !Sub
- |-
## Velocity Template used for API Gateway request mapping template
## "@@" is used here as a placeholder for '"' to avoid using escape characters.
#set($includeHeaders = true)
#set($includeQueryString = true)
#set($includePath = true)
#set($requestContext = '')
#set($inputString = '')
#set($allParams = $input.params())
#set($allParams.header.apigw-request-id = $context.requestId)
{
"stateMachineArn": "${stateMachineArn}",
#set($inputString = "$inputString,@@body@@: $input.body")
#if ($includeHeaders)
#set($inputString = "$inputString, @@headers@@:{")
#foreach($paramName in $allParams.header.keySet())
#set($inputString = "$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.header.get($paramName))@@")
#if($foreach.hasNext)
#set($inputString = "$inputString,")
#end
#end
#set($inputString = "$inputString }")
#end
#if ($includeQueryString)
#set($inputString = "$inputString, @@querystring@@:{")
#foreach($paramName in $allParams.querystring.keySet())
#set($inputString = "$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.querystring.get($paramName))@@")
#if($foreach.hasNext)
#set($inputString = "$inputString,")
#end
#end
#set($inputString = "$inputString }")
#end
#if ($includePath)
#set($inputString = "$inputString, @@path@@:{")
#foreach($paramName in $allParams.path.keySet())
#set($inputString = "$inputString @@$paramName@@: @@$util.escapeJavaScript($allParams.path.get($paramName))@@")
#if($foreach.hasNext)
#set($inputString = "$inputString,")
#end
#end
#set($inputString = "$inputString }")
#end
## Check if the request context should be included as part of the execution input
#if($requestContext && !$requestContext.empty)
#set($inputString = "$inputString,")
#set($inputString = "$inputString @@requestContext@@: $requestContext")
#end
#set($inputString = "$inputString}")
#set($inputString = $inputString.replaceAll("@@",'"'))
#set($len = $inputString.length() - 1)
"input": "{$util.escapeJavaScript($inputString.substring(1,$len))}"
}
- stateMachineArn: !Ref UpdatePrescriptionStatusStateMachineArn
IntegrationResponses:
- StatusCode: 200
ResponseTemplates:
Expand All @@ -214,9 +278,9 @@ Resources:
ResponseTemplates:
application/json: |-
#set($context.responseOverride.header["Content-Type"] ="application/fhir+json")
{"resourceType":"OperationOutcome","issue": [{"severity":"error","code":"processing","diagnostics":"System error"}]}
{"resourceType":"OperationOutcome","issue": [{"severity":"error","code":"processing","diagnostics":"System error"}]}
- StatusCode: 500
SelectionPattern: ^5\d{2}.*
SelectionPattern: ^5\d{2}.*
ResponseTemplates:
application/json: |-
#set($context.responseOverride.header["Content-Type"] ="application/fhir+json")
Expand Down

0 comments on commit abfde9f

Please sign in to comment.