Skip to content

FIX Redirect back when file validation fails.#1414

Open
erikfrerejean wants to merge 2 commits intosilverstripe:6.4from
erikfrerejean:fix/correct-redirect-on-file-validation-fail
Open

FIX Redirect back when file validation fails.#1414
erikfrerejean wants to merge 2 commits intosilverstripe:6.4from
erikfrerejean:fix/correct-redirect-on-file-validation-fail

Conversation

@erikfrerejean
Copy link

@erikfrerejean erikfrerejean commented Nov 12, 2025

Description

When file validation fails the user should be redirected back to the form, Controller::curr()->redirectBack(); doesn't perform the actual redirect but provides the redirect response. Therefore the response should be returned, not a null.

Manual testing steps

Setup a userform with a file field and upload a file that fails validation, you should be redirected back to the form with an error message.

Issues

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
    • Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green
@erikfrerejean erikfrerejean force-pushed the fix/correct-redirect-on-file-validation-fail branch from e50f1cc to da4241d Compare November 12, 2025 09:22
@erikfrerejean erikfrerejean changed the title Redirect back when file validation fails. FIX Redirect back when file validation fails. Nov 12, 2025
Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

Thanks for implementing a fix. Small change below.
Can you please also have a go at implementing a unit test for this?

On failed file validation actually return the redirect response rather then a hard `null`.
@erikfrerejean erikfrerejean force-pushed the fix/correct-redirect-on-file-validation-fail branch from 7416ec2 to dd5a652 Compare November 13, 2025 08:07
@erikfrerejean
Copy link
Author

@GuySartorelli I've added a test case but can't get the tests running from the module so I'm not sure whether or not it is actually working as expected.

@GuySartorelli
Copy link
Member

Thanks for that. The tests should be runnable locally, but I've run them here now also. Looks like there's some failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants