API: moving a page node into a folder that already has a page with that name returns 500 (UniqueViolationError) instead of 409

Aperta
#6,920 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
73/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
postgresql, python
Ambito
api, backend, databases

Direzione di ricerca

Start with api/http.py at api_update_page_node and engine/memory_engine.py at update_page_node, where the reported unique constraint violation occurs. Compare this PATCH path with the page creation path that already returns 409 for a duplicate name. Done when a same-folder rename or move collision returns HTTP 409 with a conflict message instead of 500.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

core
Bug Description

PATCH /v1/default/banks/{bank_id}/pages/nodes/{node_id} (and its deprecated alias /knowledge-base/nodes/{node_id}) with a parent_id whose folder already holds a page of the same name (case-insensitive) fails with HTTP 500. The server log shows an unhandled asyncpg.exceptions.UniqueViolationError on uq_kp_folder_pagename from update_page_node (api_update_page_node in api/http.py). Creating a page with a taken name answers 409 ("A page named '…' already exists in this folder"), so a client can't tell this conflict from a server fault, and a retrying client retries it forever.

Steps to Reproduce
  1. Create folder F, and page A named "Example" in F.
  2. Create page B named "Example" at the root (or in another folder).
  3. PATCH .../pages/nodes/{B} with {"parent_id": "<F>"}.

The same happens when a rename ({"name": ...}) collides within one folder.

Expected Behavior

409 with a message naming the conflict, as for creation.

Actual Behavior

500, with this in the server log:

Error in PATCH /v1/default/banks/<bank>/pages/nodes/<id>: duplicate key value violates unique constraint "uq_kp_folder_pagename"
DETAIL:  Key (bank_id, COALESCE(parent_id, ''::character varying), lower(name))=(...) already exists.
  File "/app/api/hindsight_api/api/http.py", line 7125, in api_update_page_node
  File "/app/api/hindsight_api/engine/memory_engine.py", line 21582, in update_page_node
asyncpg.exceptions.UniqueViolationError: ...
Version

Hindsight API 1.2.3 (self-hosted)

Lingua principale
Python
Stelle
45.2k
Fork
5.9k
Merge medio
6h 18m
PR unite (30g)
354

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vectorize-io/hindsight

Tutte le issue di vectorize-io/hindsight

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.