Skip to content

Standardize frontend on country_id instead of tax_benefit_model_name #802

@anth-volk

Description

@anth-volk

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

  1. Change Household type field from tax_benefit_model_name: TaxBenefitModelName to country_id: CountryId
  2. Update all API modules (datasets, regions, parameters, variables, economyAnalysis, simulations, households) to send country_id
  3. Update all adapters, hooks, migration orchestrators, and utilities
  4. Deprecate countryIdToModelName/modelNameToCountryId as identity functions
  5. Deprecate TaxBenefitModelName type as alias for CountryId
  6. Update all test fixtures and unit tests

Supersedes #774. Companion to PolicyEngine/policyengine-api-v2-alpha#108.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions