An empty relation property key from the LLM rejects the whole insert.text

Aperta Adatta ai principianti
#339 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend, databases

Direzione di ricerca

Leggi src/selfgraph/extraction/extractor.py nella parte relativa a _assemble e add_relation, quindi confronta _require_clean_json con _require_json_mapping in src/selfgraph/_ops.py. Controlla i test dell’extractor per la convalida delle proprietà delle relazioni e aggiungi test per una chiave vuota o composta solo da spazi. Il lavoro è completato quando la relazione viene scartata con un avviso extraction_partial_failure, mentre le relazioni valide della stessa inserzione vengono memorizzate.

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

Descrizione

approved-for-pr area: extraction bug effort: S P2

What happens

An extracted relation whose properties has an empty or whitespace-only key passes the extractor's per-item checks, then validate_facts rejects it and the whole insert.text fails. Nothing is inserted, and the message does not say which relation is at fault.

Other bad property values in the same place (control-character keys, NUL values, unsafe integers, nesting deeper than 64) are dropped one relation at a time with extraction_partial_failure, as intended.

Reproduce

On main (5a277c9), embedded Kuzu:

import asyncio, tempfile
from selfgraph import KuzuStore, SelfGraph

class LLM:
    async def generate(self, *, system, user, output):
        kind = next(iter(output.model_fields))
        if kind != "relations":
            return {kind: []}
        return {"relations": [
            {"from_name": "Ann", "type": "KNOWS", "to_name": "Bob"},
            {"from_name": "Ann", "type": "LIKES", "to_name": "Pizza", "properties": {"": 1}},
        ]}

async def main():
    with tempfile.TemporaryDirectory() as tmp:
        async with SelfGraph(store=KuzuStore(f"{tmp}/g.kuzu"), llm=LLM()) as g:
            await g.insert.text("Ann knows Bob and likes pizza.")

asyncio.run(main())

Raises ValidationError: properties keys cannot be empty or whitespace. Expected: Ann KNOWS Bob stored, the LIKES relation dropped with a warning.

Cause

_assemble's add_relation checks properties with _require_clean_json (src/selfgraph/extraction/extractor.py), which has no empty-key rule. _require_json_mapping in src/selfgraph/_ops.py does reject empty keys, but only later, in validate_facts, where one failure rejects the batch. The error there also has no relation id or field.

Lingua principale
TypeScript
Stelle
173
Fork
58
Merge medio
6h
PR unite (30g)
120

Preparare l'ambiente

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 hydra-db/selfgraph

Tutte le issue di hydra-db/selfgraph

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.