Skip to content

Fix AttributeError in bulk_tag when tagging from search results#12222

Merged
jimchamp merged 1 commit intointernetarchive:masterfrom
yukiwangg:12221/fix/bulk-tag-book-page-edit
Apr 13, 2026
Merged

Fix AttributeError in bulk_tag when tagging from search results#12222
jimchamp merged 1 commit intointernetarchive:masterfrom
yukiwangg:12221/fix/bulk-tag-book-page-edit

Conversation

@yukiwangg
Copy link
Copy Markdown
Contributor

@yukiwangg yukiwangg commented Mar 30, 2026

Add missing book_page_edit default to web.input(). Change subject field defaults from '' to [].

Closes #12221

fix

Technical

bulk_tag.py's POST handler accesses i.book_page_edit but never declares it in web.input(). When the bulk tagger is used from search results, the frontend does not send book_page_edit, causing AttributeError: 'book_page_edit' and a 500 response.

This PR:

  • Adds book_page_edit='' to web.input() so it defaults to a falsy value when not sent

  • Adds tests for the fix

Testing

  1. Log in as admin (openlibrary@example.com / admin123)

  2. Go to /search?q=tom+sawyer

  3. Click on a search result row to select it (blue highlight)

  4. Click "Tag Works" in the bottom toolbar

  5. Add any subject and click Submit

AND

docker compose run --rm home make test

Screenshot

N/A

Stakeholders

yukiwangg@

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='')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE

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', [])),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is totally unrelated to the linked issue. Revert this, and remove the associated tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE

@jimchamp jimchamp added the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label 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
@yukiwangg yukiwangg force-pushed the 12221/fix/bulk-tag-book-page-edit branch from 2f6027d to a0572a4 Compare April 1, 2026 05:26
@github-actions github-actions Bot removed the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label Apr 1, 2026
Copy link
Copy Markdown
Collaborator

@jimchamp jimchamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yukiwangg. This is working as expected.

@jimchamp jimchamp merged commit 79ff82f into internetarchive:master Apr 13, 2026
4 checks passed
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 this pull request may close these issues.

Bulk tagging from search results fails with AttributeError: 'book_page_edit'

2 participants