Skip to content

Backend validation error disappears when the user saves another field #4380

Closed

Description

@Bjarnisan

Description of the bug

A save only returns issues from the validators that ran. A custom validator whose HasRelevantChanges returns false is left out of the response. Since #3753 (October 2025), useUpdateIncrementalValidations rebuilds the backend validations from the cached initial validations and the last save only. So when the user saves a field that runs another validator, an error from an earlier save disappears from the form. The backend still has the error and blocks submit, but the user no longer sees why.

This is the bug from #1848, which #1865 fixed in 2024. Before #3753, BackendValidation.tsx kept the validator groups between saves in a ref. #3753 moved the incremental update into a hook that starts from the cached initial validations every time.

Expected: an error from a validator that did not run on the last save stays until that validator runs again, or the initial validations are fetched again.

Steps To Reproduce

  1. Make an app (Altinn.App 8, app-frontend v4) with two IFormDataValidators, one for a phone number field and one for an email field. Each returns true from HasRelevantChanges only when its own field has changed. The phone validator returns an error when the phone number is 123.
  2. Type 123 in the phone number and leave the field. The save returns the error from the phone validator, and it is shown under the field.
  3. Change the email and leave the field. The save returns only the email validator, with no issues.
  4. The phone number error is gone from the form. GET /instances/{id}/validate still returns it, and process/next answers 409 «Validation failed for task» with the same issue.

The error only disappears when the save returns at least one other validator. If no validator runs, the frontend skips the update and the error stays.

Additional Information

Seen on 16 October 2026 with app-frontend 4 from the CDN, and with main (3ef668f) built locally and loaded through localtest's frontendVersion cookie.

After step 2:

Image

After step 3:

Image

In Nordre Follo kommune we have about 80 apps on Altinn.App 8 and app-frontend v4. 38 of our validators run on save. 36 of them return true from HasRelevantChanges so that their errors are not lost, which means they run on every save. The other two are in apps that have no other validator that runs on save, so they are not hit today.

I have a fix with tests and will open a PR that refers to this issue. v9 (src/App/frontend in altinn-studio) builds the validations the same way, also for component validations.

Activity

  1. added
    kind/bug
    and removed on Oct 20, 2026
  2. added theissue type on Oct 20, 2026
  3. self-assigned this
    on Oct 20, 2026
  4. moved this to 👷 In progress in Team Altinn Studioon Oct 20, 2026
  5. olemartinorg commented on Oct 20, 2026

    @olemartinorg
    Contributor

    Thanks for the detailed report, both PRs, and the regression tests! We’ve reviewed the v4 fix and confirmed your diagnosis.

    Our existing Cypress test returns no validator groups on the later save, which skips the update and hides the bug. It misses the case where another validator returns a group.

    We’ll follow up with a separate PR in the v9 monorepo to cover successive saves with different validators, including preserving skipped validators’ errors and clearing them when their validator runs again without issues.

  6. moved this from 👷 In progress to ✅ Done in Team Altinn Studioon Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions