Skip to content

Conversation

@nicki-nhs
Copy link
Contributor

@nicki-nhs nicki-nhs commented Jan 19, 2026

Description

  • Checks whether routing configs reference given template ID when attempting to delete a template and prevents the action if so
  • Creates new "Delete error" page which lists the routing configs referencing the template
  • Updates lock number validation response to 400 from a 409
Screenshot 2026-01-21 at 17-13-04 Delete template error - NHS Notify

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.

@nicki-nhs nicki-nhs requested review from a team as code owners January 19, 2026 15:00
sidnhs
sidnhs previously approved these changes Jan 20, 2026
logger.error('Failed to save template', error);

if (
error.errorMeta?.description?.includes('linked to active message plans')
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure about relying on the error text here for error handling. I guess it's okay because it's our own API but just a gut feeling that this isn't the best way.

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 feel the same way, but unfortunately the error code just ends up as a 400 which we use for other things... any thoughts on what we should do instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

you could use the details property returned from the API on a failure response. So something like

errorMeta?.details?.errorCode === 'ERR_001' 

IIRC details is an unknown type so might need some shenangians there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, but aren't we still just comparing strings if we put something in there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a potentially shorter one, I grant you, but do you feel that adding another field to compare a different string seems like it solves the problem of 'using string comparison to determine the error' enough?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see an issue/problem with string comparison. It's how errors are handled all over the place and I don't see any difference here.

I guess it's more of what we're checking? Using what looks like an error description/text seems less intentional than an error code.

Core recently went through and removed alot of cases where error descriptions were used and replaced them with errorCodes. Having an API return an error code is pretty standard practice too.

--

Altnernative thoughts with what currently exsists (not saying do these or that they're good ideas):

  1. Delete template API ernd point could really only return a few HTTP status codes: 204, 400 and maybe a 500. We could instead say "When delete API returns a 400 then it means it's being used elsewhere so trying to delete it is a bad request".
  2. Use the errorMeta.actualError to throw a custom error and on the consumer side new-up the error and do some sort of instanceof MyCustomError check.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just my 2 cents.

Not saying anything needs to change. The PR is functionally fine. I'm not all that bothered.

);

expect(deleteResponse.status()).toBe(409);
expect(deleteResponse.status()).toBe(400);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a discussion to be had about how much we want in these API tests, but the blocked delete case potentially should be included?

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