You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test(mcp): parity test for cache-hit vs API-fallback variant details path
Defense against the class of divergence bug that #564 and the Copilot
finding on PR #717 each exposed one facet of: cache rows and attrs
``Variant`` models have subtly divergent field shapes, and any helper
that reads them with a single attribute name silently loses data on
one side.
The two prior fixes were per-field:
- ``_dump_list``: handle attrs ``to_dict`` alongside pydantic
``model_dump`` (config_attributes / custom_fields)
- ``_attr(v, "type") or _attr(v, "type_")``: read both names (the
attrs ``Variant`` discriminator is renamed for Python-keyword
collision)
Both bugs surfaced as silent ``None`` / ``ValidationError`` only on
the cold-cache call. Anything else with the same root cause would
have the same failure mode and would similarly only surface in
production. Enumerating every possible field-shape difference doesn't
scale — but exercising both paths with the same logical variant and
asserting the responses match catches the whole class at once.
``test_get_variant_details_cache_hit_and_api_fallback_paths_match``:
builds the variant twice — once as a cache-shape dict (with cache-
synthesized ``display_name`` / ``parent_name``), once as a real attrs
``Variant`` (without them). Runs both through
``_get_variant_details_impl`` (parent + supplier shared between
runs), dumps both responses, and asserts dict equality with a clear
diff on failure.
Verified the test catches divergence: temporarily reverted the
``type_`` fallback locally and the test failed with::
assert {'type': 'product'} == {'type': None}
0 commit comments