Fix: Add FastAPI validation bounds and test suites for patron check-ins and yearly goals endpoints (#13150) - #13156
Merged
jimchamp merged 1 commit intoJul 17, 2026
Conversation
Collaborator
|
Thanks for the PR, @RsbhThakur! @jimchamp is assigned to this PR and currently has:
PR triage checklist (maintainers / Richy)
Note This comment was automatically generated by PAM, Open Library's Project AI Manager. PAM provides status visibility, performs basic project management functions, and gives actionable feedback so contributors aren't left waiting. |
jimchamp
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #13150
This PR fixes missing date range bounds, malformed edition key crashes, and unvalidated path parameters in FastAPI patron check-ins (
openlibrary/fastapi/checkins.py) and yearly reading goals (openlibrary/fastapi/yearly_reading_goals.py) endpoints, and adds two dedicated unit test suites.Technical
In
openlibrary/fastapi/checkins.py:CheckInRequest:year(gt=0, le=9999),month(ge=1, le=12), andday(ge=1, le=31).edition_key: Field(None, pattern=r"(?i)^(?:/books/)?OL\d+M$").is_valid_dateanddatetime.date(y, m, d)in@model_validator(mode="after")to reject invalid calendar dates (e.g., Feb 31st).Annotated[int, Path(gt=0)]constraints towork_idandcheck_in_idpath parameters.edition_idasintbefore passing toBookshelvesEvents.In
openlibrary/fastapi/yearly_reading_goals.py:gt=0, le=9999bounds toReadingGoalItem.year,ReadingGoalForm.year, and theGET /reading-goal.json?year=query parameter.In
[NEW] openlibrary/tests/fastapi/test_checkins.pyand[NEW] openlibrary/tests/fastapi/test_yearly_reading_goals.py:Testing
Automated Unit Tests:
Output:
12 passed, 5 warnings in 6.03sScreenshot
N/A (Backend FastAPI validation & test suite implementation).
Stakeholders
@jimchamp