Python accepts from_ as a relation key in a schema; TypeScript rejects it
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, typescript
- Ambito
- backend-api-design, databases
Direzione di ricerca
Leggi src/selfgraph/schema.py nelle vicinanze di RelationType e src/selfgraph/models.py nelle vicinanze di _unknown_key; confronta le chiavi di input accettate con il comportamento del validatore TypeScript descritto nell’issue. Riproduci la validazione con from_ e poi con from e from_, in Python e TypeScript. Il lavoro è completato quando entrambi gli SDK accettano la chiave documentata from e restituiscono errori unknown_key coerenti per from_.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
A schema relation written with the key from_ instead of from is accepted by Python as the from endpoint, including its max_count. TypeScript rejects the same schema with unknown_key and suggests from. from_ is only Python's internal attribute name for the field; the documented key is from.
Tested at 04862c4 (current main), Python 3.14 and Node 26.12.
Reproduce
from selfgraph import Schema
s = Schema.model_validate({
"entities": [{"name": "Person"}],
"relations": [{"type": "WORKS_AT", "from_": {"types": ["Person"], "max_count": 1}}],
})
print(s.relations[0].from_)
types=['Person'] min_count=None max_count=1
TypeScript, same object: ValidationError, code unknown_key, field relations[0].from_:
unknown key 'from_' in schema.relations[0]; did you mean 'from'? (valid keys: type, description, aliases, synonyms, certified, from, to, properties)
So a schema that works with the Python SDK, CLI, or MCP server is rejected by the TypeScript ones, and its max_count only takes effect in Python.
Writing both keys gives a Python error that names a key the user should never need to know about:
from selfgraph import Schema
Schema.model_validate({"relations": [{"type": "X", "from": {"types": ["A"]}, "from_": {"types": ["B"]}}]})
selfgraph.errors.ValidationError: invalid schema: relations[0].from_: extra inputs are not permitted
TypeScript reports the same unknown key as above.
Cause
RelationType sets model_config = {"populate_by_name": True} (src/selfgraph/schema.py:161), so pydantic fills from_ (declared with alias="from" at :157) from either key. The unknown-key check in _unknown_key treats both the alias and the attribute name as accepted keys (accepted = set(keys) | set(model.model_fields), src/selfgraph/models.py:223), so from_ is never reported. Accepting only the alias for input, as TypeScript does, would make both SDKs return the same unknown_key error.
- 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 ·