Skip to content

Migrate lists_json GET/POST endpoints to FastAPI#12633

Merged
RayBB merged 19 commits into
internetarchive:masterfrom
Shikhar-395:feature/migrate-lists-json-to-fastapi
May 20, 2026
Merged

Migrate lists_json GET/POST endpoints to FastAPI#12633
RayBB merged 19 commits into
internetarchive:masterfrom
Shikhar-395:feature/migrate-lists-json-to-fastapi

Conversation

@Shikhar-395

@Shikhar-395 Shikhar-395 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Part of #12487 (partial — lists_json only)

Summary

  • Migrates lists_json GET (people, books, works, authors, subjects) and POST endpoints from web.py to FastAPI, delegating to legacy handlers
  • Extracts get_lists_json_data, get_lists_json_doc, and _changequery helpers from the legacy class to support FastAPI context bridging
  • Adds test coverage for pagination clamping, 404, 403, spam detection, and ClientException handling

Stakeholder

@RayBB

@mekarpeles

Copy link
Copy Markdown
Member

Thanks for the contribution, @Shikhar-395!

🤖 Copilot has been assigned for an initial review.

@RayBB is assigned to this PR and currently has:

  • 8 open PR(s) of equal or higher priority to review first
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the lists_json (aka .../lists.json) endpoints from legacy web.py to FastAPI while delegating the core behavior to the existing legacy handler logic via newly extracted helpers.

Changes:

  • Added FastAPI GET routes for people, books, works, authors, and subjects lists.json endpoints and a FastAPI POST route for creating /people/{username}/lists.json.
  • Extracted get_lists_json_doc, get_lists_json_data, and _changequery helpers from the legacy lists_json handler to support FastAPI context bridging.
  • Added FastAPI tests covering pagination clamping, 404/403 cases, spam detection, and ClientException handling.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
openlibrary/fastapi/lists.py Implements FastAPI GET/POST handlers for .../lists.json, delegating to legacy list logic and formatting responses as JSON.
openlibrary/plugins/openlibrary/lists.py Adds reusable helper functions extracted from the legacy handler to allow FastAPI to call into the existing logic.
openlibrary/tests/fastapi/test_lists.py Adds tests for the new FastAPI lists.json behavior and error handling.

Comment thread openlibrary/plugins/openlibrary/lists.py Outdated
Comment thread openlibrary/fastapi/lists.py Outdated
@RayBB

RayBB commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Converting this to a draft until it’s passing the pre-commit checks and the merge conflicts are resolved.

@RayBB RayBB marked this pull request as draft May 5, 2026 22:47
@RayBB

RayBB commented May 8, 2026

Copy link
Copy Markdown
Collaborator

@Shikhar-395 you'll also need to rebase or merge master now that the first PR for this file was merged.

@RayBB RayBB added the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label May 8, 2026
…ists-json-to-fastapi

# Conflicts:
#	openlibrary/fastapi/lists.py
#	vendor/infogami
@github-actions github-actions Bot removed the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label May 8, 2026

@RayBB RayBB left a comment

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.

@Shikhar-395 the tests are still failing. You can look at some of the other recent PRs on this file to see how changquery was dealt with and to get a better idea of the basic patterns we want to follow. Tag me when you're ready for review.

If you don't want to keep working on this let me know as well.

@github-project-automation github-project-automation Bot moved this from Waiting Review/Merge from Staff to Someone else is working on it in Ray's Project May 13, 2026
@Shikhar-395 Shikhar-395 marked this pull request as ready for review May 16, 2026 21:48
@Shikhar-395 Shikhar-395 requested a review from RayBB May 19, 2026 14:23

@RayBB RayBB left a comment

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.

Great work here.

Tested endpoints:

https://openlibrary.org/people/raybb/lists.json
https://openlibrary.org/books/OL24764889M/lists.json
https://openlibrary.org/works/OL5734718W/lists.json
https://openlibrary.org/authors/OL1394244A/lists.json
https://openlibrary.org/subjects/fiction/lists.json

Offset and limit are also working as expected.
Also the post request is working.

I did go ahead and simplify the code quite a bit and split out the endpoints so the openapi spec is more useful (doesn't have tones of params not needed for each endpoint).

@RayBB RayBB self-requested a review May 20, 2026 20:01
@RayBB

RayBB commented May 20, 2026

Copy link
Copy Markdown
Collaborator

@Shikhar-395 again, great work here. Thanks for you help and please review the changes to learn from them!

@RayBB RayBB merged commit 0236096 into internetarchive:master May 20, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Someone else is working on it to Done in Ray's Project May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants