Skip to content

Show custom error page when welsh form is archived#1969

Merged
DavidBiddle merged 5 commits intomainfrom
show-custom-error-page-when-welsh-form-is-archived
Mar 18, 2026
Merged

Show custom error page when welsh form is archived#1969
DavidBiddle merged 5 commits intomainfrom
show-custom-error-page-when-welsh-form-is-archived

Conversation

@DavidBiddle
Copy link
Contributor

@DavidBiddle DavidBiddle commented Mar 16, 2026

What problem does this pull request solve?

Trello card: https://trello.com/c/KGHod5dY/2856-iterate-the-404-page-for-archived-welsh-forms

Adds a new page to show users a specific error message when a form is no longer available in Welsh. It will display when:

  • there is a live English form document
  • there is an archived Welsh for document
  • the user has tried to access the Welsh version of the form.

As part of this, there's a small refactor which makes the FormDeocumentRepository return nil instead of throwing an error if no form document is found. This makes it easier to use the repository's find method to check the existence of a form document without adding repetitive error handling.

A GOV.UK-styled page with Welsh heading 'Mae'n ddrwg gennym, nid yw'r gwasanaeth hwn ar gael yn Gymraeg mwyach', body text Mae'r fersiwn Gymraeg o'r ffurflen hon wedi'i harchifo ac nid yw ar gael mwyach. Gallwch lenwi'r ffurflen yn Saesneg o hyd:' and a link to 'A Welsh form'

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

@DavidBiddle DavidBiddle force-pushed the show-custom-error-page-when-welsh-form-is-archived branch 2 times, most recently from f2a79ec to 97d2a06 Compare March 16, 2026 15:37
@DavidBiddle DavidBiddle reopened this Mar 16, 2026
@DavidBiddle DavidBiddle marked this pull request as ready for review March 16, 2026 15:38
The `find` method in `FormDocumentService` was implemented to throw an `ActiveResource::ResourceNotFound` error if the form wasn't found, or if the form_id was in an invalid format. This meant that methods using `find` would have to implement their own error handling logic, which can become repetitive and less readable in methods with multiple calls to `find`.

This commit updates the method to rescue the error and return `nil` if the form can't be found.
@DavidBiddle DavidBiddle force-pushed the show-custom-error-page-when-welsh-form-is-archived branch 2 times, most recently from 5068575 to 450db42 Compare March 17, 2026 10:42
thomasiles
thomasiles previously approved these changes Mar 17, 2026
Copy link
Contributor

@thomasiles thomasiles left a comment

Choose a reason for hiding this comment

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

This looks neat and works for me locally.

Showing the archived welsh page does mean 4 API calls to the admin. I've left a suggestion but I don't know that its any better or if its something worth bothering about. If we did want to optimise it in the future, I guess changing the API to let the runner know what state the form is in might be better.

DavidBiddle and others added 3 commits March 17, 2026 14:48
Reorganises the code to prevent us fetching the live English form from
the API twice.

Co-authored-by: Thomas Iles <tom.iles@digital.cabinet-office.gov.uk>
We generally aim to keep page titles in sync with the main heading on
the page - this makes it easier for screen reader users to understand
what page they're on as they navigate through a form.
@DavidBiddle DavidBiddle force-pushed the show-custom-error-page-when-welsh-form-is-archived branch from 14b71f3 to 083ca68 Compare March 17, 2026 14:53
@sonarqubecloud
Copy link

@github-actions
Copy link
Contributor

🎉 A review copy of this PR has been deployed! It is made of up two components

  1. A review copy of forms-runner
  2. A production copy of forms-admin

Important

Not all of the functionality of forms-runner is present in review apps.
Functionality such as sending emails, file upload, and S3 submission types are
deliberately disabled for the sake of simplifying review apps.

You should use the full dev environment to test the functionality which is disabled here.

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

@DavidBiddle DavidBiddle added this pull request to the merge queue Mar 18, 2026
Merged via the queue into main with commit 0bb161c Mar 18, 2026
6 checks passed
@DavidBiddle DavidBiddle deleted the show-custom-error-page-when-welsh-form-is-archived branch March 18, 2026 09:32
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.

2 participants