Fix AttributeError in bulk_tag when tagging from search results#12222
Merged
jimchamp merged 1 commit intointernetarchive:masterfrom Apr 13, 2026
Merged
Conversation
jimchamp
reviewed
Mar 31, 2026
| raise web.unauthorized() | ||
|
|
||
| i = web.input(work_ids='', tags_to_add='', tags_to_remove='') | ||
| i = web.input(work_ids='', tags_to_add='', tags_to_remove='', book_page_edit='') |
Collaborator
There was a problem hiding this comment.
Suggested change
| i = web.input(work_ids='', tags_to_add='', tags_to_remove='', book_page_edit='') | |
| i = web.input(work_ids='', tags_to_add='', tags_to_remove='', book_page_edit=False) |
book_page_edit is meant to be a boolean. It should be false by default.
jimchamp
reviewed
Mar 31, 2026
Comment on lines
+42
to
+45
| 'subjects': uniq(w.get('subjects', [])), | ||
| 'subject_people': uniq(w.get('subject_people', [])), | ||
| 'subject_places': uniq(w.get('subject_places', [])), | ||
| 'subject_times': uniq(w.get('subject_times', [])), |
Collaborator
There was a problem hiding this comment.
This is totally unrelated to the linked issue. Revert this, and remove the associated tests.
jimchamp
requested changes
Mar 31, 2026
Add book_page_edit=False to web.input() so it defaults to a falsy value when not sent by the frontend. Adds test coverage. Closes internetarchive#12221
2f6027d to
a0572a4
Compare
jimchamp
approved these changes
Apr 13, 2026
Collaborator
jimchamp
left a comment
There was a problem hiding this comment.
Thanks @yukiwangg. This is working as expected.
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.
Add missing book_page_edit default to web.input(). Change subject field defaults from '' to [].
Closes #12221
fix
Technical
bulk_tag.py'sPOSThandler accessesi.book_page_editbut never declares it inweb.input(). When the bulk tagger is used from search results, the frontend does not sendbook_page_edit, causingAttributeError: 'book_page_edit'and a 500 response.This PR:
Adds
book_page_edit=''toweb.input()so it defaults to a falsy value when not sentAdds tests for the fix
Testing
Log in as admin (
openlibrary@example.com/admin123)Go to
/search?q=tom+sawyerClick on a search result row to select it (blue highlight)
Click "Tag Works" in the bottom toolbar
Add any subject and click Submit
AND
docker compose run --rm home make test
Screenshot
N/A
Stakeholders
yukiwangg@