Fix: Allow redirected authors in validation#11393
Open
SAYAN02-DEV wants to merge 2 commits intointernetarchive:masterfrom
Open
Fix: Allow redirected authors in validation#11393SAYAN02-DEV wants to merge 2 commits intointernetarchive:masterfrom
SAYAN02-DEV wants to merge 2 commits intointernetarchive:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the author page validation logic to allow redirect types alongside author types. Previously, the validation would reject redirect operations on author pages, but redirects are a legitimate type used when merging duplicate authors.
- Added
/type/redirectas an allowed type for author pages in validation checks - Updated both the early return condition and the type-changing validation to handle redirect types
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
|
@mekarpeles @cdrini I don't feel confident in reviewing this one. Could one of you take it on? |
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.
Closes #11387
Fix: Resolves validation error when editing books containing redirected author references.
Technical
Here the code checks(Line 109 and Line 121) for /type/author and if not so it doesnt proceed, which restricts editing of books that have merged authors:
openlibrary/openlibrary/plugins/openlibrary/code.py
Lines 108 to 124 in c507c96
If we allow
/type/redirectwhen validating author page types. This allows edits to proceed on records that reference merged authors, while still preventing malicious type changes.Line 109 should be
if page.type.key in ('/type/author', '/type/redirect'):Line 121 should be
elif page.type.key not in ['/type/author', '/type/redirect'] and books:Testing
Steps to reproduce the original issue:
Steps to verify the fix:
Screenshot
N/A - This is a backend validation fix with no UI changes
Stakeholders