openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Comment not saved when deleting a record

Open seabelis opened this issue 4 months ago • 2 comments

Problem

Occasionally Open Library records must be removed from the catalog completely. It is helpful to have a comment saved should the reason be questioned at a later time. However, including a comment and hitting "delete" does not actually save the comment explaining the reason for deletion.

https://openlibrary.org/books/OL57651673M?m=history

Reproducing the bug

  1. Go to ...
  2. Do ...
  • Expected behavior:
  • Actual behavior:

Context

  • Browser (Chrome, Safari, Firefox, etc):
  • OS (Windows, Mac, etc):
  • Logged in (Y/N):
  • Environment (prod, dev, local): prod

Breakdown

Implementation Details (for maintainers)

Requirements Checklist

  • [ ]

Related files

Stakeholders


Instructions for Contributors

  • Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.

seabelis avatar Jul 27 '26 16:07 seabelis

Noting that comments are persisted when authors are deleted. This issue affects edition and work records.

jimchamp avatar Jul 28 '26 23:07 jimchamp

Context

Codebase research confirms the root cause and shows it is already fixed on master:

  • The "Delete Record" button lived in its own <form id="delete-record">, separate from the main edit form (id="addWork"/id="addAuthor") that contains the _comment text input rendered by EditButtons.html. Submitting the delete form therefore never included the comment field — openlibrary/templates/books/edit.html#L45-L47.
  • By contrast, type/author/edit.html associates its delete button with the main form via the HTML form="addAuthor" attribute, so the comment is submitted for author deletions — matching @jimchamp's comment above that author-delete comments persist while edition/work-delete comments did not.
  • The backend was already comment-aware: SaveBookHelper.save() reads formdata.pop("_comment", "") and passes it through to delete(), which calls doc._save(comment=comment) — openlibrary/plugins/upstream/addbook.py#L556-L571. The bug was purely that the comment value never reached the delete request.
  • This issue is already resolved. PR internetarchive/openlibrary#13223 ("Persist comments when books are deleted", merged 2026-07-29) closes this issue. It adds a click handler (initRecordDeletion) that appends the _comment input into the delete form and calls form.requestSubmit(elem) before the delete form is submitted. The current master checkout already has this fix in place (edit.js, index.js, and the class="delete-record" hook in edit.html).

Issue Assessment

Action items

  • [x] Is this already fixed? (Answer: Yes — see PR #13223, merged 2026-07-29, which closes this issue and matches the root cause found in research above.)

Needs: Lead has been removed (superseded by the existing Lead: @jimchamp label). Needs: Triage and Needs: Breakdown remain applied per the label table's stated removal conditions, but given the fix has already merged and shipped, a maintainer may want to clear these during triage.

🔔 Stakeholders

No new stakeholder ping needed — @jimchamp (already tagged as Lead) authored and merged the fix in #13223.

Full triage checklist
  • [x] Triage — correct labels applied or removed (Needs: Lead removed as superseded; Needs: Triage/Needs: Breakdown left for maintainer judgment given the merged fix)
  • [x] Problem / opportunity — problem is clear, audience identified (librarians deleting records), actionable
  • [x] Scope — well-scoped; single, narrow bug
  • [ ] Justification — no explicit measurable impact/frequency stated in the original report
  • [ ] Success & testing criteria — no explicit "definition of done" in the issue body itself
  • [ ] Proposal & breakdown — issue's own Breakdown section was left as unfilled placeholders (moot now — fix already merged)
  • [ ] If bug: environment & repro steps — Browser/OS/repro steps left blank in the template
  • [x] Risks, concerns, open questions — none outstanding; resolved by research above
  • [x] Richy context — relevant code, commits, PRs reviewed; superseding PR (#13223) found and confirmed as the fix, no duplicate
  • [x] References — permalinks to the exact code and fixing PR provided above

[!NOTE] This comment was automatically generated by Richy, Open Library's issue enrichment assistant, on behalf of @mekarpeles. This is NOT a sign-off. This issue needs lead review before work begins.

openlibrary-bot avatar Jul 31 '26 07:07 openlibrary-bot