Skip to content

Return latest form document version from the API - #3020

Draft
stephencdaly wants to merge 4 commits into
mainfrom
handle-form-versions-in-api
Draft

Return latest form document version from the API#3020
stephencdaly wants to merge 4 commits into
mainfrom
handle-form-versions-in-api

Conversation

@stephencdaly

@stephencdaly stephencdaly commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What problem does this pull request solve?

Trello card: https://trello.com/c/dGv0TrD1

Change the indexes on the form_documents table to allow for multiple versions of a form to exist.

Make the forms API consumed by forms-runner handle a form having multiple form document versions. It works as follows:

  • If the tag param is “draft”, return the only draft form document
  • If the tag param is “live” return the form document if the latest version is live. Return a 404 if the latest version is archived
  • If the tag param is “archived” return the form document if the latest version is archived. Return a 404 if the latest version is live

It will return the latest form document for the requested language - even if there is a higher version number for another language. This should handle the situation where a Welsh form document has been archived and a new version of the English form has been created. Forms runner handles this by rendering a page saying the form was archived with a link to the English 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?

Allow:
- One form_document with the same language and version per form
- One form_document with the same language and a null version per form
to account for draft forms
Returns the live or archived form document for the given form ID and
language with the highest version number.
We've made it possible for multiple form documents with the same
language and tag to exist with different version numbers.

Update the forms API to return the latest version of the form
document with the given language, if the tag matches the requested
tag. If the draft tag is requested, the only draft form document for
the language will be returned.

This means that the behaviour of the API remains unchanged externally
once we are retaining form documents for previous versions.
@stephencdaly
stephencdaly force-pushed the handle-form-versions-in-api branch from e64afaa to db12671 Compare August 13, 2026 11:25
@github-actions

Copy link
Copy Markdown

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-3020.admin.review.forms.service.gov.uk/

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.

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.

1 participant