Skip to content

Commit 67ed0f4

Browse files
authored
Print specific message if CORE row isn't found (#99)
* Print specific message if CORE row isn't found * Introducing terraform-docs * GitHub workflow fixes * Removing terraform-docs * Just a rename * Secret change and documentation fixes
1 parent eb8d689 commit 67ed0f4

5 files changed

Lines changed: 29 additions & 14 deletions

File tree

.github/workflows/pr.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
## When copying this to a new ORC repository...
22
##
3-
## 1) Create environments for dev, test, pre-prod and prod (https://github.com/nhsconnect/<repo>/settings/environments).
3+
## 1) Visit https://github.com/nhsconnect/<repo>/settings/environments and create environments:
4+
## - dev
5+
## - test
6+
## - test-apply
7+
## - pre-prod
8+
## - pre-prod-apply
9+
## - prod
10+
## - prod-apply
411
##
512
## 2) For each environment, add the following secrets:
6-
## - BACKEND_BUCKET
7-
## - BACKEND_KEY
8-
## - IAM_ROLE_READONLY
13+
## - IAM_ROLE
14+
## - TF_BACKEND_BUCKET
15+
## - TF_BACKEND_DYNAMODB_TABLE
16+
## - TF_BACKEND_KEY
917
##
1018
## 3) Create the following repository secret (https://github.com/nhsconnect/<repo>/settings/secrets/actions):
1119
## - ECR_REPOSITORY_NAME
1220
##
1321
## 4) Edit the ## REPOSITORY SPECIFIC ## section below.
1422

15-
name: Terraform Plan
23+
name: PR Checks
1624
on:
1725
pull_request:
18-
branches: [ main ]
26+
branches:
27+
- main
1928

2029
permissions:
2130
contents: read # Required for actions/checkout
@@ -42,7 +51,7 @@ jobs:
4251
strategy:
4352
matrix:
4453
environment: [dev, test, pre-prod, prod]
45-
name: ${{ matrix.environment }}
54+
name: Terraform Plan (${{ matrix.environment }})
4655
runs-on: ubuntu-latest
4756
environment: ${{ matrix.environment }}
4857
defaults:
@@ -58,7 +67,7 @@ jobs:
5867
- name: Configure AWS Credentials
5968
uses: aws-actions/configure-aws-credentials@v4
6069
with:
61-
role-to-assume: ${{ secrets.IAM_ROLE_READONLY }}
70+
role-to-assume: ${{ secrets.IAM_ROLE }}
6271
aws-region: eu-west-2
6372

6473
- name: terraform fmt

src/api/patients/patient-details-controller.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
getCurrentConversationIdForPatient,
77
getMessageIdsForConversation
88
} from '../../services/database/ehr-conversation-repository';
9-
import { HealthRecordNotFoundError } from '../../errors/errors';
9+
import { HealthRecordNotFoundError, CoreNotFoundError } from '../../errors/errors';
1010

1111
export const patientDetailsValidation = [
1212
param('nhsNumber')
@@ -52,6 +52,12 @@ export const patientDetailsController = async (req, res) => {
5252
return;
5353
}
5454

55+
if (err instanceof CoreNotFoundError) {
56+
logInfo('Did not find a core message');
57+
res.sendStatus(503);
58+
return;
59+
}
60+
5561
logError('Could not retrieve patient health record', err);
5662
res.sendStatus(503);
5763
}

src/errors/errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class HealthRecordNotFoundError extends Error {
1212
}
1313
}
1414

15-
export class MessageNotFoundError extends Error {
15+
export class CoreNotFoundError extends Error {
1616
constructor(error) {
1717
super(errorMessages.MessageNotFound);
1818
logError(errorMessages.MessageNotFound, error);

src/services/database/__tests__/ehr-conversation-repository.integration.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
import { createCore } from '../ehr-core-repository';
1818
import { EhrTransferTracker } from '../dynamo-ehr-transfer-tracker';
1919
import { markFragmentAsReceivedAndCreateItsParts } from '../ehr-fragment-repository';
20-
import { HealthRecordNotFoundError, MessageNotFoundError } from '../../../errors/errors';
20+
import { HealthRecordNotFoundError, CoreNotFoundError } from '../../../errors/errors';
2121
import moment from 'moment-timezone';
2222

2323
jest.mock('../../../middleware/logging');
@@ -247,7 +247,7 @@ describe('ehr-conversation-repository', () => {
247247
// when
248248
await expect(() => getMessageIdsForConversation(conversationId))
249249
// then
250-
.rejects.toThrowError(MessageNotFoundError);
250+
.rejects.toThrowError(CoreNotFoundError);
251251
});
252252

253253
it('should return health record extract message id given a conversation id for a small health record', async () => {

src/services/database/ehr-conversation-repository.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ConversationStatus, HealthRecordStatus, RecordType } from '../../models
22
import { logError, logInfo } from '../../middleware/logging';
33
import { EhrTransferTracker } from './dynamo-ehr-transfer-tracker';
44
import { buildConversationUpdateParams, isInCompleteStatus } from '../../models/conversation';
5-
import { HealthRecordNotFoundError, MessageNotFoundError } from '../../errors/errors';
5+
import { HealthRecordNotFoundError, CoreNotFoundError } from '../../errors/errors';
66
import { isCore } from '../../models/core';
77
import { isFragment } from '../../models/fragment';
88
import { buildSoftDeleteUpdateParams } from '../../utilities/dynamodb-helper';
@@ -125,7 +125,7 @@ export const getMessageIdsForConversation = async (conversationId) => {
125125
const fragments = items.filter(isFragment);
126126

127127
if (!core) {
128-
throw new MessageNotFoundError();
128+
throw new CoreNotFoundError();
129129
}
130130
const coreMessageId = core.InboundMessageId;
131131
const fragmentMessageIds = fragments.map((message) => message.InboundMessageId);

0 commit comments

Comments
 (0)