Skip to content

DF-1248: Add error details when previewing a form - #1257

Merged
alexluckett merged 36 commits into
mainfrom
feat/preview-error-details
Aug 10, 2026
Merged

DF-1248: Add error details when previewing a form#1257
alexluckett merged 36 commits into
mainfrom
feat/preview-error-details

Conversation

@alexluckett

@alexluckett alexluckett commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

This PR depends on DEFRA/forms-engine-plugin#459.

When a form is broken, the error page currently displays a standard HTTP 500 page. This PR introduces an error page specifically for form previews to tell the form designer what is broken.

This page is only shown when accessing a preview form. Live submissions will not show it.

This page is only displayed if the error is related to the form definition or form metadata. Standard errors during a preview will show up as the standard HTTP 500 page.

Jira ticket: DF-1248

Invalid form definition

image

Invalid metadata

image

Unknown page controllers

image

Unknown components

image

@alexluckett alexluckett changed the title Add error details when previewing a form DF-1248: Add error details when previewing a form Aug 6, 2026
tsc --noEmit flagged three issues in the drift-canary test: a delete
on a required (non-optional) list property, and two mockResolvedValue
calls where the fixture's widened engine: string type didn't match
FormDefinition's Engine enum. Swap the delete for
Reflect.deleteProperty and cast the fixtures through unknown at the
two call sites, matching the existing pattern used elsewhere in the
repo (e.g. save-and-exit.js).
@alexluckett
alexluckett force-pushed the feat/preview-error-details branch from 9a44b85 to c86eb33 Compare August 10, 2026 10:20
"canYou": "You can:",
"tryBack": "try your browser back button as your data may be saved",
"contact": "<a class=\"govuk-link\" href=\"https://www.gov.uk/guidance/contact-defra\">contact the Defra Helpline</a> if you have any questions"
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You seem to have omitted the translations for the cy.json file. Since the error pages now (always) have a language selector - irrespective of whether the form has translations or not - we will need the Welsh translations for this page.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I actually left them off intentionally since this is for internal workers only, the language toggle will display but it won't do anything and will fall back to English. We don't actually need Welsh here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it be sensible to hide the language selector then on the error details page? That would just be a case of removing 'languages' from the viewModel, I think


const text = parts.join('\n')

return text.length > MAX_TECHNICAL_LENGTH

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The ellipsis can be done purely using CSS in the UI but I guess physically truncating the payload here is the correct approach to prevent bleed.

Comment thread src/server/plugins/errorInterpretation.js
*/
function buildDefinitionCauses(joiError) {
return [
...new Set(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice

Comment thread src/server/plugins/errorInterpretation.js
Comment thread package.json Outdated
"@hapi/wreck": "^18.1.2",
"@hapi/yar": "^11.0.3",
"@types/humanize-duration": "^3.27.4",
"accessible-autocomplete": "^3.0.1",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We shouldn't need to include accessible-autocomplete here. It's only when using npm link that it disappears (so I manually copy from plugin node-modules to runner node_modules temporarily). When using a proper plugin npm version, accessible-autocomplete is pulled in from plugin, and therefore not needed in the runner package.json

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops, thanks. Accidental commit from development.

@alexluckett
alexluckett force-pushed the feat/preview-error-details branch from f77aad8 to d6b1d63 Compare August 10, 2026 13:26
@sonarqubecloud

Copy link
Copy Markdown

@alexluckett
alexluckett merged commit 94d24bc into main Aug 10, 2026
9 checks passed
@alexluckett
alexluckett deleted the feat/preview-error-details branch August 10, 2026 13:43
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