edit engagement: unhide error messages, fix testing lead error #4078
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the engagement form contained an error while editing an engagement, the error was not shown. This was a generic issue, but we saw it in these cases:
This PR ensures error messages are shown and fixes the bug around the testing lead field validation.
The cause of the testing lead problem was that on the form GET the list of testing leads was generated successfully using the authorization helper.
But on form POST the
id
of aProduct
instead of theproduct
model instance itself got passed into the form. This cascaded into the authorization helper function where the check on theid
always resulted inFalse
. This lead to the form concluding the chosen lead was not allowed.This is a corner case / programming error, but got swallowed by the way the authorization helper was built. This PR also makes the authorization helper more strict and throws an error if someone passes in an
id
instead of anobject
. (If we only get an id, the authorization helper doesn't which type it is and has no other choice but to raise an error.)