Skip to content

Conversation

@rasmi
Copy link
Contributor

@rasmi rasmi commented Dec 30, 2025

The Variables refactor (#859) changed the structure of VariableConfig objects but didn't include migration for existing experiments, causing them to crash when loading (see #909).

Old format (pre-v19):

{
  variableNames: string[],
  schema: TSchema,
  seedStrategy: SeedStrategy,
  values: string[]
}

New format (v19+):

{
  definition: { name, description, schema },
  scope: VariableScope,
  shuffleConfig: ShuffleConfig,
  values: string[],
  numToSelect?: number,
  expandListToSeparateVariables?: boolean
}

Changes

  • utils/src/variables.legacy.utils.ts - Migration utilities with migrateVariableConfig() and migrateVariableConfigs()
  • utils/src/variables.utils.ts - extractVariablesFromVariableConfigs() now auto-migrates old configs as a runtime fallback
  • functions/src/migrations/migrate-variable-configs.ts - One-time Firestore migration script

Running the Migration

Option 1: One-time database migration

cd functions

# Preview changes first
npm run migrate:variable-configs:dry-run

# Apply changes
npm run migrate:variable-configs

For production, set GOOGLE_APPLICATION_CREDENTIALS or use gcloud auth application-default login.

Option 2: Runtime migration (automatic fallback)

Old configs are automatically migrated at runtime when extractVariablesFromVariableConfigs() is called. This ensures experiments load even if the database migration hasn't been run, but the one-time script may be preferable for a full fix.

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