-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error handling for updating valkyrie collections #5610
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
improves readability of the update method
The approach is based on the same change that was made for works in [PR #5448](https://github.com/samvera/hyrax/pull/5448/files#diff-843d5f344066ba9de62a999cf88a87b29479b10988676c0bc474f4853e2adaf4) and for create valkyrie collections in (PR #5604)[https://github.com/samvera/hyrax/pull/5604/files].
_NOTE: This change will be superceded by the work in PR #5458_
cjcolvar
reviewed
Apr 29, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I had a couple questions about what might be slight changes in behavior.
For backward compatibility, errors are returned as simple strings for create and update collections when the collection is an ActiveFedora collection. For Valkyrie collections, errors are converted to a JSON hash with more information about the response. This is how works respond when there is an error. So going forward, it is better to have consistent error processing.
cjcolvar
approved these changes
May 2, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
When processing an update for a valkyrie collection, the updated collection instance was not being handled correctly when failures occurred.
If the form validation failed, the updates were not processed and
after_update
was called instead ofafter_update_error
.If the transactions failed,
@collection
was set to false by.value_or
before it called `after_update_error.Similar issues were happening with the create process that were fixed in PR #5604.
WAS:
Now, the form validation is processed before setting @collection. If a failure occurs, the process is aborted and calls after_update_errors. Likewise, if there is a failure during the transaction process, after_update_errors is called to process the error and redisplay the edit form.
@collection
is only updated if there are no form or transaction failures.NOTE: This PR also moves after and before methods for update to private, deprecating the public versions. This is consistent with the pattern used in works and for create collection.
Related work
The approach is based on the same change that was made for works in PR #5448.
This is follow-on work for the changes to the create collection process in PR #5604.
@samvera/hyrax-code-reviewers