diff --git a/src/ibek/ioc.py b/src/ibek/ioc.py index 078559080..d568d35f0 100644 --- a/src/ibek/ioc.py +++ b/src/ibek/ioc.py @@ -27,9 +27,21 @@ class Entity(BaseSettings): ) __definition__: Definition - @model_validator(mode="after") # type: ignore + @model_validator(mode="before") # type: ignore def add_ibek_attributes(cls, entity: Entity): - """Whole Entity model validation""" + """ + Whole Entity model validation + + TODO at present an object reference to an ID where the referred object violates + schema is seen as "KeyError: "object XXX not found in [...]" which hides the + schema violation error. + + This could potentially be fixed by doing the validation here instead + (removing extra:forbid from the model_config). BUT, at present passing + the info arg to this function receives a dict of the IOC instance + that created this entity, not the entity itself. This may be a + pydantic bug? + """ # find the id field in this Entity if it has one ids = set(a.name for a in entity.__definition__.args if isinstance(a, IdArg)) diff --git a/tests/samples/generate_samples.sh b/tests/samples/generate_samples.sh index 322eff3ee..48fc228d7 100755 --- a/tests/samples/generate_samples.sh +++ b/tests/samples/generate_samples.sh @@ -13,6 +13,7 @@ export DEFS=${SAMPLES_DIR}/../../ibek-defs # this is so relative schema mode lines work cd $SAMPLES_DIR +set -x echo making the support yaml schema ibek ibek-schema ${SAMPLES_DIR}/schemas/ibek.defs.schema.json