Deleting check-in event errors if just added
Problem
When removing the “Already Read” date from a book, the frontend sends a DELETE request to an incorrect endpoint:
DELETE /check-ins/
This results in a 404 Not Found, and the deletion action fails.
Reproducing the bug
- Go to My Books → Currently Reading / Already Read
- Open any book with a recorded “Already Read” date
- WITHOUT REFRESHING THE PAGE, Try to remove or update the read date
- Open DevTools → Network tab
- Observe the request:
Thank you @akramcodez for submitting this issue!
⚠️ Contributors, this issue will be ready to work on once:
- [ ] Triage — maintainers will add
Priority: *andLead: @*to replaceNeeds: TriageandNeeds: Lead
Context
Root cause traced to openlibrary/plugins/openlibrary/js/my-books/MyBooksDropper/CheckInComponents.js.
The submit-check-in event handler (~line 151) calls postCheckIn() and checks resp.ok, but never parses the response body. The FastAPI endpoint (openlibrary/fastapi/checkins.py:90) returns {status: "ok", id: <event_id>} on success, but this id is never passed to checkInForm.setEventId(). As a result, the form's hidden event_id input remains empty after a fresh check-in creation.
The DELETE handler (CheckInComponents.js:246) constructs /check-ins/${eventId} — when eventId is "", the URL becomes /check-ins/, reproducing the reported 404.
This is distinct from the bug fixed in PR #12394 (merged, closes #12391), which added a .json route alias for the POST endpoint. The same reporter (@akramcodez) flagged this eventId retention issue in a comment on #12391, but it was not included in that PR's changes — only openlibrary/fastapi/checkins.py was modified (+1 line).
The fix is isolated: update the submit-check-in handler to parse the JSON response and call this.checkInForm.setEventId(String(data.id)). Once triaged, this may qualify as a Good First Issue — single-file JS change, clear acceptance criteria, no deep codebase knowledge required.
Issue Assessment
Open questions
- Is the 404 also reproducible on page reload with a pre-existing read date (i.e., is there a separate path where
event_idisn't passed from the server), or only after creating a check-in in the same browser session without reloading?
Action items
- [ ] In
CheckInComponents.js, update thesubmit-check-inhandler to parse the POST response (resp.json()) and callthis.checkInForm.setEventId(String(data.id))with the returned event ID before callingupdateDateAndShowDisplay - [ ] Add a regression test (JS or integration) verifying that DELETE succeeds immediately after a fresh check-in POST without a page reload
Full triage checklist (maintainers / Pam)
- [ ] Triage — correct labels applied or removed:
Needs: Breakdown,Needs: Investigation,Needs: Design,Needs: Staff Decision,Needs: Staff / Admin,Good First Issue,Blocked,Blocker - [x] Problem / opportunity — problem is clear, audience identified, actionable
- [x] Scope — issue is well-scoped; single-file JS fix
- [x] Justification — deletion of read dates is broken for check-ins created in the same session
- [ ] Success & testing criteria — no explicit test plan; a regression test is needed
- [x] Proposal & breakdown — fix location identified (
CheckInComponents.jssubmit-check-inhandler);Needs: Breakdownremoved - [x] If bug: environment & repro steps — repro steps and network trace screenshot provided
- [ ] Risks, concerns, open questions — whether this also affects pre-existing read dates (separate server-side path) is unconfirmed
- [x] Pam context — root cause confirmed in
CheckInComponents.js; related fix in PR #12394 verified not to cover this code path; no duplicate issue found - [x] References — screenshot and network trace in issue body
[!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.
If this is a real bug, I’d like to work on it.
This could have been an artifact of attempting to migrate this endpoint to FastAPI (and we've temporarily put it back to webpy so it should presumably work)?
I switched the haproxy redirect back to webpy while this is a problem
Actually that didn't help... Looking at it further it seems like the bug only presents when you do it on the same page. If you reload the page, then you can delete without issue. Updated reproduction steps.
Hi @RayBB and @cdrini! I'd like to work on this issue.
My understanding of the bug:
When a check-in event is added and then deleted on the same page (without refreshing), the DELETE request is sent to /check-ins/ with no ID, resulting in a 404. This happens because the submit-check-in event handler in CheckInComponents.js calls postCheckIn() but never parses the response body to extract the returned id — so the newly created event's ID is never stored for subsequent deletion.
Proposed fix:
Parse the JSON response from postCheckIn() to capture the returned id, then use it when constructing the DELETE request URL.
Could I be assigned to this issue? Thank you!
@joannajiang711 you're assigned. Good luck.
When you open your PR please include a video showing this working locally.