bug(api): [E_UNIQUE] tentrance - duplicate j_document_entrance on permanent merge delete
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 50/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, nodejs
- Ambito
- api
Direzione di ricerca
The failing call is TEntrance.addToCollection(mergeIntoId, 'documents', newDocuments) in api/controllers/v1/entrance/delete.js around line 259, which builds the document list for the permanent merge. Read how that list is assembled, then compare with the organization merge fix referenced in #1757 to see how already-linked documents are skipped. To reproduce, link one document to two entrances and call the permanent merge delete endpoint. Done when the merge returns success with no duplicate junction row; the partial-commit question is a separate issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
Permanently deleting an entrance while merging it into another (isPermanent=1&entityId=<target>) returned a 500 after 14.4 s. TEntrance.addToCollection(mergeIntoId, 'documents', newDocuments) tries to insert a j_document_entrance row for a document that is already linked to the target entrance, and Waterline reports a uniqueness violation. The merge code does not remove documents the target already has.
To Reproduce
- Link the same document to two entrances (A and B)
DELETE /api/v1/entrances/A?isPermanent=1&entityId=BaddToCollectionfails on the duplicate pair.
Input Data
- Endpoint:
DELETE /api/v1/entrances/119655?isPermanent=1&entityId=25308 - Request Body: none
- URL/Query Parameters:
isPermanent=1,entityId=25308 - User: id 32181, groups Administrator, Moderator, User, Leader
- Log line:
Permanent merge entrance 119655: {"action":"merge","entranceId":119655,"mergeIntoId":25308,"locations":[],"descriptions":[],"riggings":[],"histories":[],"comments":[],"documents":[24390],"names":[275487],"cave":120704}
Expected behavior
Documents already linked to the surviving entrance are skipped (same approach as the organization merge in #1757), and the merge completes.
Error Details
- Error Type:
AdapterError: Would violate uniqueness constraint-- a record already exists with conflicting value(s). - Occurrences: 1 in this triage window (1 in the 30d retention)
- Time Range: 2026-10-09T13:09:23Z
- Representative Trace ID:
01a120c8-2040-7270-82e2-2ff4329c2951 - Stack Trace:
AdapterError: Would violate uniqueness constraint-- a record already exists with conflicting value(s).
at node_modules/waterline/lib/waterline/methods/add-to-collection.js:424:19
(call site: api/controllers/v1/entrance/delete.js:259, TEntrance.addToCollection)
Front-end request record
- Client:
37.69.231.57, Chrome 154 on Android 10 - Duration: 14433 ms, response size
[not captured] - Retry sequence on
/api/v1/entrances/119655: 13:07:25 DELETEentityId=25308200 (694 ms, soft delete), 13:09:23 DELETEisPermanent=1&entityId=25308500 (14.4 s). No retry afterwards.
Partial-success check (separate defect)
Before the failing step, the controller runs earlier steps (see the lines above 259) before the failing call. delete.js does not wrap the sequence in a transaction, so steps preceding line 259 may be committed while the entrance still exists as soft-deleted. [open question]: run SELECT id, is_deleted FROM t_entrance WHERE id = 119655; and compare j_document_entrance for 119655 vs 25308 to see what was applied.
Additional context
- Service:
api/controllers/v1/entrance/delete.js:259 - Model:
tentrance(junctionjdocumententrance) - DB Error Code:
[not logged](Waterline E_UNIQUE wrapped as AdapterError) - Related: #1572 (same junction, different cause: the PUT link endpoint), #1757 (same pattern fixed for organizations)
- Lingua principale
- JavaScript
- Stelle
- 18
- Fork
- 3
- Merge medio
- 1g 56m
- PR unite (30g)
- 41
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di GrottoCenter/grottocenter-api
-
Priority: Low Production Type: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
GrottoCenter/grottocenter-api#1903 ·
I maintainer di solito rispondono entro 1 giorno
-
Priority: Low Type: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
GrottoCenter/grottocenter-api#1858 ·
I maintainer di solito rispondono entro 1 giorno
-
bug(api): [500] document - multer Request aborted on POST /api/v1/documents treated as server errorApertaPriority: Low Type: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
GrottoCenter/grottocenter-api#1808 ·
I maintainer di solito rispondono entro 1 giorno
-
Priority: Low Type: Feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
GrottoCenter/grottocenter-api#1732 ·
I maintainer di solito rispondono entro 1 giorno
-
Document the two-phase delete pattern to prevent recurring false-positive code review feedbackAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
GrottoCenter/grottocenter-api#1654 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di GrottoCenter/grottocenter-api
Issue simili
-
bug/1-unconfirmed kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 74/100
521xueweihan/HelloGitHub#4010 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
BUG
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG]: filesystem-edit-file converts a CRLF file's line endings to LF on every editForse già presa @MohammadHijjawi97 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
Mintplex-Labs/anything-llm#6755 ·
I maintainer di solito rispondono entro 1 giorno