Change embargo/lease ID types to fix nil values being converted to blank strings #6652
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.
Fixes
Fixes #6650 ; refs #6521
Summary
When using a Valkyrie adapter, the attribute type for
embargo_id
andlease_id
is currentlyValkyrie::Types::ID
. Because of the behavior of that type, if those attributes get set to a blank string, they will get persisted asValkyrie::ID @id=""
. This is problematic when round-tripping them through URI/ID conversions in the fedora adapter (see Description section.) This PR changes toValkyrie::Types::Params::ID
, because blank strings are always returned asnil
, whereasValkyrie::Types::ID
returns exactly what it is given, and a blank string is still a valid string.Guidance for testing, such as acceptance criteria or new user interface behaviors:
In a rails console (i.e. in sirenia), create a work and set a blank string on
embargo_id
:Make sure resulting
embargo_id
is stillnil
, per the behavior ofValkyrie::Types::Params::ID
Detailed Description
Per the summary, this is a problem when/if IDs like
embargo_id
andlease_id
are ever changed fromnil
to a blank string. But why would we want to do that? We don't, but it is consistently demonstrable when a work is related to an admin set with a one-step workflow. It's not clear where/why this happens.This isn't a problem for the postgres adapter, but for fedora, those IDs are stored as URIs. When those get ran through URI-to-ID conversion by the fedora metatdata adapter, it returns what's anchored at the end, which is just the fedora base path (i.e.
development
etc.) because there is no trailing ID. Conversely, when that value is ran through ID-to-URI conversion, it gets appended to the configured base path, so it ends up withhttp://fedora_url/base_path/base_path
.This introduces breakage because the
embargo_id
andlease_id
is no longernil
or blank, so it triggers methods that it should have short-circuited, with invalid URIs that are guaranteed to produceLdp::NotFound
errors. This produces confusing behavior; in the case of #6521, the error came from loading the object forembargo_id
when the work wasn't even under embargo.The effect of changing the attribute type is that, even though something in Hyrax workflows is inappropriately trying to change
nil
values to a blank string, theValkyrie::Types::Params::ID
will convert them back tonil
when persisted; that's what the type is designed for.@samvera/hyrax-code-reviewers