Skip to content

Migrate merge_authors_json to FastAPI#12918

Merged
RayBB merged 5 commits into
internetarchive:masterfrom
Sanket17052006:migrate-merge-authors-json
Jun 17, 2026
Merged

Migrate merge_authors_json to FastAPI#12918
RayBB merged 5 commits into
internetarchive:masterfrom
Sanket17052006:migrate-merge-authors-json

Conversation

@Sanket17052006

@Sanket17052006 Sanket17052006 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Closes #

This PR migrates the merge_authors_json web.py handler to FastAPI.

Technical

  • AddMergeAuthorsBody Pydantic model for request validation
  • Uses shared LibrarianDep dependency injection for auth
  • Replaced web.ctx.sitesite.get() ContextVar in merge_authors.py and edits.py
  • Marked legacy class with @deprecated

Testing

docker compose run --rm home pytest openlibrary/tests/fastapi/test_merge_authors.py -v

Login:

curl -s -c /tmp/cookies.txt -X POST "http://localhost:8080/account/login.json" \
  -H "Content-Type: application/json" \
  -d '{"username":"openlibrary","password":"openlibrary"}'

POST merge authenticated → 200:

curl -s -b /tmp/cookies.txt -X POST "http://localhost:18080/authors/merge.json" \
  -H "Content-Type: application/json" \
  -d '{"master": "/authors/OL1A", "duplicates": ["/authors/OL2A"]}'

POST unauthenticated → 401:

curl -s -w "\nHTTP %{http_code}" -X POST "http://localhost:18080/authors/merge.json" \
  -H "Content-Type: application/json" \
  -d '{"master": "/authors/OL1A", "duplicates": ["/authors/OL2A"]}'

Screenshot

Stakeholders

@RayBB

@Sanket17052006 Sanket17052006 force-pushed the migrate-merge-authors-json branch from 6303592 to 87f71eb Compare June 13, 2026 10:40
@Sanket17052006 Sanket17052006 marked this pull request as draft June 13, 2026 11:18
@Sanket17052006 Sanket17052006 marked this pull request as ready for review June 14, 2026 08:28
@RayBB RayBB self-assigned this Jun 15, 2026
@github-project-automation github-project-automation Bot moved this to Waiting Review/Merge from Staff in Ray's Project Jun 15, 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.

Carefully tested this locally then on testing. It's kind of annoying to test there because you need to craft a fetch to run appropriately. But it did work great!

Thanks for getting this one done and it seems to be much much faster!

@RayBB RayBB merged commit c3f8e0d into internetarchive:master Jun 17, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting Review/Merge from Staff to Done in Ray's Project Jun 17, 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.

2 participants