Migrate patrons_follows_json endpoint to FastAPI - #12869
Conversation
|
Thanks for the PR, @Sanket17052006. 🤖 Copilot has been assigned for an initial review. There are currently 76 open non-draft PRs ahead of yours in the queue. A reviewer has not yet been assigned to this PR. Possible improvements for this PR
PR triage checklist (maintainers / Pam)
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. |
There was a problem hiding this comment.
Pull request overview
This PR migrates the legacy patrons_follows_json web.py handler to FastAPI by introducing GET/POST /people/{username}/follows.json, adding a FollowEntry response model, deprecating the old handler, and adding FastAPI tests to cover the new behavior.
Changes:
- Added FastAPI
GET /people/{username}/follows.jsonto return a user’s follow list (or redirect to login). - Added FastAPI
POST /people/{username}/follows.jsonto subscribe/unsubscribe (or redirect to login / 404 on missing publisher). - Added a new FastAPI test suite for the follows endpoints and marked the legacy web.py handler as deprecated.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| openlibrary/fastapi/internal/api.py | Adds FollowEntry plus new GET/POST follows endpoints in FastAPI. |
| openlibrary/plugins/openlibrary/api.py | Marks the legacy patrons_follows_json web.py handler as deprecated. |
| openlibrary/tests/fastapi/test_follows.py | Adds FastAPI tests for GET/POST follows behavior, redirects, and 404 handling. |
|
@Shikhar-395 could you please test and review this? |
|
Verdict: Needs changes for one routing issue. FindingThis PR adds the FastAPI handlers for
Please add: (r"(/people/[^/]+)/follows", "json"), |
|
Hey @Shikhar-395, I've addressed the review and added the legacy route pattern to DEPRECATED_PATHS. Please take a look! |
d549be0 to
c6d18a8
Compare
RayBB
left a comment
There was a problem hiding this comment.
Put it on testing and it's working flawlessly.
Great work @Sanket17052006 and @Shikhar-395 !

Closes #
This PR migrates the
patrons_follows_jsonweb.py handler to FastAPI.Technical
GET /people/{username}/follows.jsonFastAPI handlerPOST /people/{username}/follows.jsonFastAPI handlerFollowEntryPydantic response model.@deprecated("migrated to fastapi")Testing
Test file :
docker compose run --rm home pytest openlibrary/tests/fastapi/test_follows.py -vScreenshot
N/A
Stakeholders
@RayBB