Skip to content

Conversation

@ClareJonesBJSS
Copy link
Contributor

@ClareJonesBJSS ClareJonesBJSS commented Jan 27, 2026

Description

  • Retrieve routing config before submit (implicitly validating name etc via zod parsing)
  • Explicitly check for null defaultTemplateIds
  • Add missing/deleted/unproofed template check to ddb txn

Removes the option of null language/accessibility templateIds, as this was not actually being leveraged and getting rid simplifies both this validation and core events

Context

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming
  • If I have used the 'skip-trivy-package' label I have done so responsibly and in the knowledge that this is being fixed as part of a separate ticket/PR.

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

@ClareJonesBJSS ClareJonesBJSS requested review from a team as code owners January 27, 2026 17:01
@ClareJonesBJSS ClareJonesBJSS force-pushed the feature/CCM-12685_validate-submitted-config branch 6 times, most recently from 8bab989 to b2f4edc Compare January 28, 2026 09:47
'Test Template for Submit'
);

await templateStorageHelper.seedTemplateData([template]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to do a cleanup of this template data at the end? we're doing that in other places in the test suite

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

alexnuttall
alexnuttall previously approved these changes Jan 28, 2026
alexnuttall
alexnuttall previously approved these changes Jan 28, 2026
if (currentLockNumber !== lockNumber) {
return failure(
ErrorCase.CONFLICT,
'Lock number mismatch - Message Plan has been modified since last read'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'Lock number mismatch - Message Plan has been modified since last read'
'Lock number mismatch - Routing configuration has been modified since last read'

}

const submittableValidationError =
this.parseSubmittableRoutingConfig(cascade);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it might be clearer to do this inline rather than extracting into this other function?
and also, the 400 it returns if its invalid will clash with the 400 for already submitted, does that matter?

Update: update,
},
// Template existence check + For LETTER templates, check they have PROOF_APPROVED or SUBMITTED status
// Also exclude DELETED templates for all template types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also be validating that the templates belong to the same client? or, given we do that when we add them to the message plan, are we assuming you couldnt have got in that state?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition check is doing this - both the update and the condition check use the same user.clientId as the owner partition key.

('DELETED' satisfies RoutingConfigStatus)
) {
missingTemplateIds.push(templateId);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it not possible that you get ConditionalCheckFailed errors for other template types?
or letters that failed for reasons other than not being in submitted/proof approved?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so? In the case where the template ID doesn't exist or isn't owned by the client, !reason.Item will apply (and I feel treating ownership mismatch as not found is correct), and DELETED and invalid LETTER statuses are the only other conditions in the statement.

actualError: err,
errorMeta: {
code: 500,
description: 'Error retrieving Routing Config',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you not update these error messages to be routing configuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh fair spot, it was some 404s that I renamed as we had two different wordings and it was bugging me, so I went with the switch that touched the fewest lines, might as well do it here too

});
});

test('returns 404 failure if transaction fails because routing config does not exist', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the two descriptions, its not massively clear to me how this test and the one above are different , do they maybe need rewording, if we need them both?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this covering is the logically possible but massively unlikely scenario where the routing config item is deleted from DynamoDB between sending the GetItem command and sending the TransactWrite command. I think the test is valuable but I agree the descriptions could be a little clearer - maybe include the command names in them?

expect(mocks.dynamo).not.toHaveReceivedCommand(TransactWriteCommand);
});

test('returns validation failure if defaultTemplateId is null with no conditionalTemplates', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think similar here - I feel like these two test descriptions sound the same?

});
expect(res.success).toBe(false);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about test for invalid with conditional template with a null template ID?

});
});

test('returns 404 failure if transaction fails because routing config does not exist', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this covering is the logically possible but massively unlikely scenario where the routing config item is deleted from DynamoDB between sending the GetItem command and sending the TransactWrite command. I think the test is valuable but I agree the descriptions could be a little clearer - maybe include the command names in them?

Update: update,
},
// Template existence check + For LETTER templates, check they have PROOF_APPROVED or SUBMITTED status
// Also exclude DELETED templates for all template types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition check is doing this - both the update and the condition check use the same user.clientId as the owner partition key.

@ClareJonesBJSS ClareJonesBJSS force-pushed the feature/CCM-12685_validate-submitted-config branch from 5bd3af2 to f1ae2d3 Compare February 2, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants