Skip to content

Ensure complete mappings are generated from old taxonomy versions to l… - #887

Open
katbailey wants to merge 2 commits into
mainfrom
generate-full-mappings
Open

Ensure complete mappings are generated from old taxonomy versions to l…#887
katbailey wants to merge 2 commits into
mainfrom
generate-full-mappings

Conversation

@katbailey

@katbailey katbailey commented Mar 13, 2026

Copy link
Copy Markdown
Collaborator

Problem

When generating dist mapping files (e.g., shopify_2025-09_to_shopify_2026-02.json), the chain resolution only resolves the outputs of existing rules forward through newer versions. It does not propagate rules from intermediate versions backward to older versions.

This means if a category ID existed in an older version but was only remapped in a later version, the older version's mapping file would have no entry for it — even though that ID is now invalid in the latest version. The mapping files claim to map old version → latest but are incomplete.

Approach

Modified resolve_to_shopify_mappings in IntegrationVersion to propagate rules backward after resolving existing rules. Since resolve_to_shopify_mappings_chain processes newest-to-oldest, by the time we process an older version, all newer versions' rules already have their outputs resolved to the latest taxonomy Category objects.

After the existing resolution loop, we now iterate through all newer versions' to_shopify_mappings and for each rule:

  1. Check if the input category ID exists in the current (older) version's full_names_by_id
  2. Check if the current version doesn't already have a rule for that input ID
  3. If both conditions are true, create a propagated MappingRule mapping from the older version's category entry to the newer rule's already-resolved output

Existing rules always take precedence — propagation only fills gaps.

Test plan

  • Added unit test: rule from newer version propagates to older version when category exists in full_names_by_id
  • Added unit test: existing rules are not overwritten by propagated rules
  • Added unit test: rules are not propagated for categories absent from full_names_by_id
  • Updated load_all_from_source chain test to verify propagated rule count
  • Added aa-2 to 2020-01 fixture's full_names.yml to cover the propagation scenario
  • Run generate_dist and verify mapping file completeness

@katbailey
katbailey force-pushed the generate-full-mappings branch from c2ab92d to 33c8ec2 Compare March 16, 2026 15:15
@katbailey
katbailey marked this pull request as ready for review March 16, 2026 15:19
@katbailey
katbailey requested a review from danielpgross March 16, 2026 15:19
@katbailey katbailey changed the title Ensure complete mappings are generate from old taxonomy versions to l… Ensure complete mappings are generated from old taxonomy versions to l… Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant