Ensure links are passed from DSpace object to Item#76
Merged
jonavellecuerdo merged 1 commit intoJun 17, 2026
Conversation
Why these changes are being introduced: * Testing the new digitized theses workflow revealed a bug when instantiating dspace_rest_client.models.Item objects. This ensures that links from the DSpaceObject that is returned when resolving an item handle are passed to the Item object during the 'update' operation. How this addresses that need: * Set item.links to dspace_object.links * Allow bitstream upload for items without any bitstreams in their 'ORIGINAL' bundle Side effects of this change: * None Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/IN-1759
jonavellecuerdo
commented
Jun 17, 2026
Comment on lines
+533
to
549
| if len(bitstreams) == 1: | ||
| original_bitstream = bitstreams[0] # retrieve single bitstream | ||
| self._delete_bitstream_dspace8(original_bitstream) | ||
| deleted_bitstreams.append(original_bitstream.name) | ||
|
|
||
| # note deleted bitstreams | ||
| update_messages.append( | ||
| "Full replacement of bitstreams for bundle 'ORIGINAL'." | ||
| f"The following bitstreams were removed: {deleted_bitstreams}." | ||
| ) | ||
| elif len(bitstreams) == 0: | ||
| logger.warning(f"'ORIGINAL' bundle for item '{item.handle}' is empty") | ||
| elif len(bitstreams) > 1: | ||
| raise errors.ItemError( | ||
| f"Error occurred while updating item '{item.handle}, 'ORIGINAL' " | ||
| f"bundle {bundle.uuid} contains {len(bitstreams)} bitstream(s)" | ||
| ) |
Contributor
Author
There was a problem hiding this comment.
When first writing the code for the "update" operation, it seemed like a good idea to raise an ItemError if there were no bitstreams in the 'ORIGINAL' bundle. However, in the event that there is an item with without a bitstream and we are running DSS to provide a bitstream, it makes sense to proceed with the upload!
This file contains hidden or 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
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.
Purpose and background context
Testing the new digitized theses workflow revealed a bug when instantiating dspace_rest_client.models.Item objects. This ensures that links from the DSpaceObject that is returned when resolving an item handle are passed to the Item object during the 'update' operation.
How can a reviewer manually see the effects of these changes?
The latest code updates are validated through the successful test run of the new digitized theses DSC workflow: see Jira ticket IN-1759
Includes new or updated dependencies?
YES
Changes expectations for external applications?
NO
What are the relevant tickets?
Code review