Fix: Handle malformed author entries in work merge UI #11588
+21
−3
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.
Closes #10972
Merging works with missing or malformed author entries threw
TypeError: Cannot read properties of undefinedwhen attempting to accessauthor.keyon undefined objects, preventing the merge UI from rendering.Technical
Added defensive checks at four access points where author data is read without validation:
get_author_names(): Filter malformed entries before mapping to keysenhancedRecords: Check existence before accessing properties and verify author exists in search resultshash_subel(): Fallback to JSON serialization for malformed author entriesAuthorRoleTable: Conditional render displays "(malformed author)" instead of crashingTesting
Visit merge URLs with works containing malformed authors (e.g.,
https://openlibrary.org/works/merge?records=OL16305918W,OL20650159W,OL19635988W) - UI should render successfully with graceful handling of missing author data.Stakeholders
@cdrini
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.