Malformed-type values in a transformation spec are silently coerced to strings during the SHAPE phase (ReferenceValidator.normalize()) instead of surfacing as validation errors. Pydantic alone rejects all of these; ReferenceValidator coerces them before the model ever sees them:
| Spec input |
After SHAPE |
Pydantic-alone result |
sources: 5 |
["5"] |
ValidationError |
sources: {a: 1} |
["1"] |
ValidationError |
object_derivations: "oops" |
["oops"] (then flattened to []) |
ValidationError |
ensure_list is doing two jobs at once: the desirable scalar→list convenience ("lr" → ["lr"], which the multivalued populated_from feature relies on) and an undesirable coercion of genuinely wrong types that hides the error.
This is a SHAPE/ReferenceValidator layer-wide behavior affecting every multivalued field, not specific to sources or object_derivations. Low priority — it only bites on actively malformed YAML, the common scalar/number-string case coerces to something sensible, and it predates the current normalization work.
Possible directions:
- Add a pre-SHAPE type check that rejects values that are neither a scalar of the expected type nor a list of them, before
ensure_list coerces them.
- Or a strict mode that distinguishes "scalar → one-element list" convenience from "wrong type" and fails loudly on the latter.
Surfaced during review of #250 (Copilot flagged the _flatten_ods_in_class_deriv and _migrate_pv_sources_to_populated_from MIGRATE-phase helpers, but the coercion actually happens upstream in SHAPE).
Malformed-type values in a transformation spec are silently coerced to strings during the SHAPE phase (
ReferenceValidator.normalize()) instead of surfacing as validation errors. Pydantic alone rejects all of these; ReferenceValidator coerces them before the model ever sees them:sources: 5["5"]ValidationErrorsources: {a: 1}["1"]ValidationErrorobject_derivations: "oops"["oops"](then flattened to[])ValidationErrorensure_listis doing two jobs at once: the desirable scalar→list convenience ("lr"→["lr"], which the multivaluedpopulated_fromfeature relies on) and an undesirable coercion of genuinely wrong types that hides the error.This is a SHAPE/ReferenceValidator layer-wide behavior affecting every multivalued field, not specific to
sourcesorobject_derivations. Low priority — it only bites on actively malformed YAML, the common scalar/number-string case coerces to something sensible, and it predates the current normalization work.Possible directions:
ensure_listcoerces them.Surfaced during review of #250 (Copilot flagged the
_flatten_ods_in_class_derivand_migrate_pv_sources_to_populated_fromMIGRATE-phase helpers, but the coercion actually happens upstream in SHAPE).