TypeScript CLI rejects --metadata with a __proto__ key
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
- 84/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- cli
Direzione di ricerca
Inizia da metadataOf in typescript/src/cli.ts:219-226 e confronta la sua logica di unione con quella di kv, che gestisce già __proto__ in modo sicuro. Poi trova i test di parità della CLI e aggiungi un caso --metadata per i formati JSON e KEY=VALUE. Il lavoro è completo quando la CLI TypeScript accetta e memorizza metadati con una chiave __proto__ propria, come la CLI Python e l’API.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The TypeScript CLI rejects insert text --metadata input that holds a __proto__ key, with a misleading error. The Python CLI and both APIs accept the same metadata and store it. This is the --metadata counterpart of #139, which fixed --prop.
Tested at 5a277c9 (current main), Kuzu.
Reproduce
$ selfgraph insert text "Ada Lovelace met Charles Babbage." --source-id s1 --metadata '{"__proto__": {"x": 1}, "a": 1}'
- Python CLI: succeeds and stores
metadata_json{"__proto__": {"x": 1}, "a": 1}on the source version. - TypeScript CLI:
error[invalid_argument]: metadata must be a mapping, got Object.
The KEY=VALUE form fails the same way in TypeScript:
$ selfgraph insert text "..." --source-id s2 --metadata '__proto__={"x":1}' --metadata a=1
error[invalid_argument]: metadata must be a mapping, got Object
The TypeScript API accepts the parsed object and stores the same metadata_json as Python:
await graph.insert.text("Ada Lovelace met Charles Babbage.", {
source_id: "s1",
metadata: JSON.parse('{"__proto__": {"x": 1}, "a": 1}'),
});
Cause
metadataOf in typescript/src/cli.ts:219-226 merges each value with Object.assign into a plain {}. Object.assign writes an own __proto__ key through the prototype setter, so it replaces the prototype of out instead of adding a key. requireJsonMapping then sees an object whose prototype is not Object.prototype and reports got Object. When the value is not an object, the key is silently dropped. kv already builds its map with Object.create(null) since #139, but metadataOf does not.
Suggested fix
Build the merged metadata with Object.create(null) (or define each key with Object.defineProperty / Object.fromEntries), as kv does, and add a --metadata case to the CLI parity tests.
- 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: 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
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 ·