Deeply nested JSON input to the CLI exits 1 unstructured instead of invalid_argument
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
- 74/100
Direzione di ricerca
Inizia in src/selfgraph/runtime.py, da parse_json, e ispeziona la gestione delle eccezioni. Poi segui il modo in cui cli.main segnala ValidationError. Controlla i test esistenti per il JSON malformato e aggiungi la copertura per input profondamente annidati. Il lavoro è completato quando la CLI restituisce il codice di uscita 2 con un errore strutturato invalid_argument per i casi di riproduzione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
A deeply nested JSON value passed to the CLI (as a --prop/--evidence value, an insert facts file, or inline --schema/--prompts) exits with code 1 and an unstructured error: Stack overflow ... message, rather than exit 2 with a structured invalid_argument error. parse_json catches only ValueError, but a deeply nested document makes json.loads raise a RecursionError, which is not a ValueError.
Reproduction (0.2.2)
Create a value that is 100000 nested [:
DEEP=$(python3 -c 'print("["*100000)')
selfgraph --store kuzu --uri g.kuzu entity create --name a --type T --prop "k=$DEEP"
Observed: exit code 1, error: Stack overflow (used 8144 kB) while decoding a JSON array ..., with no error[code], no field, and no hint. The same happens with an insert facts file of 200000 [ characters and with inline --schema/--prompts JSON.
Expected: exit code 2 with a structured error[invalid_argument], as other malformed JSON produces, since the input is invalid.
Cause
parse_json in src/selfgraph/runtime.py (around line 153) catches only ValueError:
try:
return json.loads(text, parse_constant=_reject_constant)
except ValueError as exc:
raise ValidationError(f"invalid JSON{where}: {exc}") from exc
A deeply nested document raises RecursionError (a RuntimeError subclass), which escapes the except ValueError and is then caught by cli.main's RuntimeError branch, which prints error: <message> with exit 1 and no code. This is the same class of gap as #347 (a reader catching too narrow an exception type). It also defeats the "parse as JSON, else keep as text" fallback used for --prop, so the value cannot fall through to text.
Expected
parse_json treats a too-deeply-nested document as invalid JSON and raises ValidationError (invalid_argument), so the CLI exits 2 with a structured error for this input like any other malformed JSON.
- 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: 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: errors area: write bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
hydra-db/selfgraph#392 · 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 ·