Skip to content

Fix missing f-string in facet_wrapper assert message (#12649)#12691

Merged
mekarpeles merged 2 commits into
internetarchive:masterfrom
tranmin001:12649/fix/fstring-facet-wrapper
May 11, 2026
Merged

Fix missing f-string in facet_wrapper assert message (#12649)#12691
mekarpeles merged 2 commits into
internetarchive:masterfrom
tranmin001:12649/fix/fstring-facet-wrapper

Conversation

@tranmin001
Copy link
Copy Markdown
Contributor

Closes #12649

[fix]

Technical

Adds the missing f prefix to the assert message string in facet_wrapper in openlibrary/plugins/worksearch/subjects.py line 337. Without the fix, the error message always printed the literal string {facet} instead of the actual facet value, making the assertion unhelpful for debugging.

This is my first open source contribution, working on it as part of a university course at UW Bothell. Open to any feedback or change!

Testing

Added openlibrary/plugins/worksearch/tests/test_subjects.py with a test that patches SUBJECTS to an empty list to trigger the assert, then verifies the error message contains the actual facet value rather than the literal string {facet}.

To run:
sudo docker compose run --rm home pytest openlibrary/plugins/worksearch/tests/test_subjects.py -v

Ran make test locally — 3780 tests passed, 1 failed. New test file: 1 passed, 0 failed.

  • OLMarkdownEditor.test.js fails due to a missing @tiptap/core dependency, pre-existing and unrelated to this change.

@mekarpeles

@mekarpeles mekarpeles requested a review from Copilot May 9, 2026 11:34
@mekarpeles
Copy link
Copy Markdown
Member

Thanks for your contribution, @tranmin001! Welcome to Open Library — this appears to be your first PR here.

🤖 Copilot has been assigned for an initial review.

The linked issue (#12649) hasn't been triaged yet — triage happens on Mondays and Fridays. There are currently 73 open non-draft PRs ahead of yours in the review queue.

PR triage checklist (maintainers / Pam)
  • PR description — not empty; explains what the change does and how to verify it
  • References an issue — PR body contains a #NNN reference
    • Linked issue is triaged — has a Priority: * label (not just Needs: Triage)
    • Linked issue is assigned — has at least one assignee
  • Commit history clean — no WIP/fixup/conflict noise; commit messages are meaningful
  • CI passing — no failing check-runs
  • Test cases present — if the change touches substantive logic, test coverage exists or is explained
  • Proof of testing — PR body includes a description of what was tested, a screenshot, or a video

Note

This comment was automatically generated by Pam, Open Library's Project AI Manager, on behalf of @mekarpeles. Pam is designed to provide status visibility, perform basic project management functions and relevant codebase research, and provide actionable feedback so contributors aren't left waiting.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an unhelpful assertion message in the WorkSearch subject facet wrapping logic by converting the string to an f-string so the failing facet value is included, and adds a regression test to ensure the assertion message contains the actual facet value.

Changes:

  • Update facet_wrapper’s assertion message to interpolate facet correctly.
  • Add a new pytest regression test that triggers the assertion and checks the error message includes the facet value.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
openlibrary/plugins/worksearch/subjects.py Fixes the assertion message to include the invalid facet value via f-string interpolation.
openlibrary/plugins/worksearch/tests/test_subjects.py Adds a regression test for the assertion message content when the facet engine lookup fails.

Comment thread openlibrary/plugins/worksearch/tests/test_subjects.py
@mekarpeles mekarpeles merged commit a378575 into internetarchive:master May 11, 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.

F-string missing in facet_wrapper assert message (worksearch/subjects.py)

4 participants