Non-string top-level key in facts or schema raises a bare TypeError in Python
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
- 77/100
Direzione di ricerca
Inizia da src/selfgraph/models.py, in particolare da as_input e _reject_unknown_keys, e leggi il contratto degli errori in AGENTS.md. Riproduci il problema con una chiave di primo livello non stringa in graph.insert.facts o as_schema, poi trova il test «every code» menzionato nell’issue. Il lavoro è concluso quando questi input generano un ValidationError con il codice unknown_key e il test copre questo comportamento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In Python, a facts or schema mapping whose top level has a key that is not a string raises a bare TypeError from pydantic instead of a coded ValidationError. The same bad key one level down gets a proper unknown_key error.
Tested at 5a277c9 (current main), Kuzu.
Reproduce
await graph.insert.facts({1: "x"})
# TypeError: keywords must be strings
await graph.insert.facts({None: []})
# TypeError: keywords must be strings
from selfgraph.schema import as_schema
as_schema({1: "x"}) # also SelfGraph(store, schema={1: "x"})
# TypeError: keywords must be strings
For comparison:
await graph.insert.facts({"entities": [{1: "x"}]})
# ValidationError[unknown_key]: unknown key '1' in facts.entities[0] (valid keys: id, type, name, ...)
as_input(ExtractionInstructions, {1: "x"}, "instructions")
# ValidationError[unknown_key]: unknown key '1' in instructions (valid keys: entities, relations, preferences, decisions)
Cause
as_input (src/selfgraph/models.py:306) calls model.model_validate(value). For the top-level input models (Extraction, Schema), which override __init__, pydantic passes the mapping on as keyword arguments, and Python rejects a non-string keyword before any validator runs. The unknown-key check in _reject_unknown_keys (models.py:270), which names the bad key for nested models and for the instructions and prompts inputs, never sees it.
The TypeScript SDK and the CLI and MCP paths cannot produce a non-string key, so only direct Python API callers reach this. Per the error contract in AGENTS.md, every failure should carry a code.
Suggested fix
Check that the top-level keys are strings in as_input (or in TopInputModel before calling super().__init__) and raise the same unknown_key ValidationError the nested models give, then add the call to the "every code" test.
- Lingua principale
- TypeScript
- Stelle
- 173
- Fork
- 58
- Merge medio
- 6h
- PR unite (30g)
- 120
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la 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 hydra-db/selfgraph
-
approved-for-pr area: cli-mcp area: errors bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
hydra-db/selfgraph#401 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: errors area: store bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
hydra-db/selfgraph#398 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: parity area: write bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
hydra-db/selfgraph#391 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: cli-mcp area: parity bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
hydra-db/selfgraph#384 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di hydra-db/selfgraph
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
code-yeongyu/senpi#7139 ·
I maintainer di solito rispondono entro 1 giorno
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficoltà 1/5 1-3 ore Idoneità per principianti 72/100
lingdojo/kana-dojo#34395 · 1 commento · 5 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
bug status: needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
mastra-ai/mastra#31093 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
area:web p2 product:business triage:active type:bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 89/100
cuadrao-ai/argus#2328 ·
I maintainer di solito rispondono entro 1 giorno
-
bug frontend good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
nikhilb2/simple_invoicing#907 ·