Problem
The frontend uses multiple conventions for identifying which country model to use when calling API v2 endpoints:
- Some calls send
country_id ("us"/"uk")
- Some send
tax_benefit_model_name with underscores ("policyengine_us")
- Some send
tax_benefit_model_name with hyphens ("policyengine-us")
- The core
Household type uses tax_benefit_model_name: TaxBenefitModelName with underscore values
- Conversion functions (
countryIdToModelName, modelNameToCountryId) exist to bridge formats
COUNTRY_TO_MODEL_NAME map stored wrong values (underscores instead of hyphens)
This causes:
- Broken metadata fetching (frontend sends underscores, DB stores hyphens)
- Infinite loops when model lookup fails and retries
- Unnecessary complexity with format conversion utilities
Solution
- Change
Household type field from tax_benefit_model_name: TaxBenefitModelName to country_id: CountryId
- Update all API modules (datasets, regions, parameters, variables, economyAnalysis, simulations, households) to send
country_id
- Update all adapters, hooks, migration orchestrators, and utilities
- Deprecate
countryIdToModelName/modelNameToCountryId as identity functions
- Deprecate
TaxBenefitModelName type as alias for CountryId
- Update all test fixtures and unit tests
Supersedes #774. Companion to PolicyEngine/policyengine-api-v2-alpha#108.
Problem
The frontend uses multiple conventions for identifying which country model to use when calling API v2 endpoints:
country_id("us"/"uk")tax_benefit_model_namewith underscores ("policyengine_us")tax_benefit_model_namewith hyphens ("policyengine-us")Householdtype usestax_benefit_model_name: TaxBenefitModelNamewith underscore valuescountryIdToModelName,modelNameToCountryId) exist to bridge formatsCOUNTRY_TO_MODEL_NAMEmap stored wrong values (underscores instead of hyphens)This causes:
Solution
Householdtype field fromtax_benefit_model_name: TaxBenefitModelNametocountry_id: CountryIdcountry_idcountryIdToModelName/modelNameToCountryIdas identity functionsTaxBenefitModelNametype as alias forCountryIdSupersedes #774. Companion to PolicyEngine/policyengine-api-v2-alpha#108.