Skip to content
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

Blank values for Valkyrie::ID attributes cause URI-to-ID lookups to return Fedora base path as ID #6650

Closed
randalldfloyd opened this issue Jan 30, 2024 · 0 comments · Fixed by #6652

Comments

@randalldfloyd
Copy link
Contributor

In Hyrax using Valkyrie (i.e. koppie and sirenia) there are demonstrable scenarios where a work's attributes get changed from nil to type Valkyrie::ID containing a blank string when saved. Specific examples are embargo_id and lease_id when a work is in a one-step workflow. This doesn't adversely affect koppie on postgres, because the blank string seems to be functionally equivalent to nil, AFAIK.

But this breaks ID handling in sirenia on fedora because the URI values on those attributes get stored in fedora as just http://fedora_url/base_path with no trailing ID. The result is that this call to translate the URI to an ID returns just the configured base_path part of the URI as if it were the ID. On the flip side, this call to translate an ID into a URI returns http://fedora_url/base_path/base_path, which will produce Ldp::NotFound errors.

In the context of Hyrax (i.e. sirenia), the actual breaking behavior can be baffling; those IDs now contain the configured base_path when they should have been nil or blank, triggering calls in parts of the stack that it should normally slip silently through. For example, this Hyrax issue describes errors while saving workflow state for a work, which is caused by Ldp::NotFound for the URI returned for embargo_id, even though it is not under embargo.

I'm opening an issue here and in Valkyrie because it's not clear if something in Hyrax or the Valkyrie persister itself is converting those ID attributes from nil to Valkyrie::ID @id="" . Also, we may have to provide a workaround on the Hyrax side if we can't find why those get converted but the behavior doesn't change on the Valkyrie side.

This problem can be demo'd in a Hyrax (sirenia) console:

persister = Hyrax.persister
monograph1 = Monograph.new

# embargo_id is initially nil
monograph1.embargo_id 
# => nil

# Set embargo_id to blank string to mimic what happens for works in a one-step workflow
monograph1.embargo_id = ""  

# Value is now blank with type of Valkyrie::ID
monograph1.embargo_id 
# => #<Valkyrie::ID:0x00007f5f73fecb88 @id="">

# Saving, which currently allows blank values for the ID attributes...
monograph1 = persister.save(resource: monograph1)

# Load the saved version to a new object, which walks attributes through URI-to-ID conversion
monograph2 = Hyrax.query_service.find_by(id: monograph1.id)

# embargo_id now equal to base_path
monograph2.embargo_id 
# => #<Valkyrie::ID:0x00007f5f6eb829a8 @id="development">

# Subsequent ID-to-URI conversion returns invalid location:
Hyrax.query_service.find_by(id: monograph2.embargo_id)

Valkyrie::Persistence::ObjectNotFoundError: Valkyrie::Persistence::ObjectNotFoundError
...
Caused by Ldp::NotFound: Error: Resource /development/development not found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant