{"record":{"id":"ad98302e013f5719","repo":"twentyhq/twenty","slug":"missing-name-env-var-ad9830","errorCode":null,"errorMessage":"Missing ${name} env var","messagePattern":"Missing (.+?) env var","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-apps/internal/twenty-partners/src/scripts/seed.ts","lineNumber":22,"sourceCode":"// 5 statuses (each linked to a partner + opportunity).\n//\n// Run from this app directory, against a running Twenty server with the app\n// installed (deploy first; do NOT run `yarn test` after — its teardown wipes the app).\n// Credentials from shell env or a gitignored .env.local (TWENTY_PARTNERS_API_URL/KEY).\n//\n//   yarn twenty dev --once\n//   tsx src/scripts/seed.ts\n\nimport { config } from 'dotenv';\nconfig({ path: process.env.ENV_FILE ?? '.env.local' });\n\nimport { CoreApiClient } from 'twenty-client-sdk/core';\n\nimport { backfillPartnerUserOnChildren } from 'src/modules/shared/services/backfill-partner-user-on-children.service';\n\nconst requireEnv = (name: string): string => {\n  const value = process.env[name];\n  if (!value) throw new Error(`Missing ${name} env var`);\n  return value;\n};\n\nconst CAL = 'https://calendly.com/placeholder';\nconst PRIMARY_DEMO_PARTNER_SLUG = 'nine-dots-ventures';\nconst PRIMARY_DEMO_BUDGET_USD = 15000;\nconst PRIMARY_DEMO_DESCRIPTION_MARKDOWN = `## About Nine Dots Ventures\n\nNine Dots helps scaling teams launch Twenty as an operational system of record, not just a CRM.\n\n### What we typically deliver\n\n- Discovery workshops to align sales, operations, and leadership.\n- End-to-end pipeline design with custom lifecycle stages.\n- Migration plans that preserve historical activities and account context.\n- Team onboarding with adoption dashboards and weekly office hours.\n\n### Why clients pick us","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-apps/internal/twenty-partners/src/scripts/seed.ts#L4-L40","documentation":"The partner `seed` script uses the same `requireEnv` pattern as the purge script: it loads `.env.local` (or `ENV_FILE`) via dotenv, then throws when any required variable is unset. The seeder bootstraps demo partners, opportunities, budgets, etc. via the CoreApiClient, so it needs the API URL and key (and any other required values) before it can write. The message is generic on purpose — the interpolated `${name}` identifies which variable is missing.","triggerScenarios":"Running `tsx src/scripts/seed.ts` (or the `yarn twenty dev --once` flow that invokes it) when the Twenty GraphQL endpoint URL, API key, or another required env var is missing from the loaded env file.","commonSituations":"New developer setup without running the dev-env setup script that copies `.env` files; switching environments without updating `ENV_FILE`; a recent script change that added a new `requireEnv` call not yet reflected in the team's `.env.example`.","solutions":["Run the repo's dev-env setup (`bash packages/twenty-utils/setup-dev-env.sh`) to copy and populate the `.env` files, then re-run the seed.","Grep the seed script and its imports for every `requireEnv('...')` call and confirm each variable exists in your `.env.local`.","Pass `ENV_FILE` explicitly if you intend a non-default file, e.g. `ENV_FILE=.env.prod tsx src/scripts/seed.ts`.","Diff your `.env.local` against `.env.example` to find any newly added required keys."],"exampleFix":"// before\nconst requireEnv = (name: string): string => {\n  const value = process.env[name];\n  if (!value) throw new Error(`Missing ${name} env var`);\n  return value;\n};\n\n// after — collect all missing vars and fail once with the full list\nconst requireEnv = (name: string): string => {\n  const value = process.env[name];\n  if (!value) {\n    throw new Error(\n      `Missing ${name} env var (loaded ${process.env.ENV_FILE ?? '.env.local'})`,\n    );\n  }\n  return value;\n};","handlingStrategy":"validation","validationCode":"const REQUIRED_SEED_ENV = ['CORE_API_URL', 'CORE_API_KEY'] as const;\nconst missing = REQUIRED_SEED_ENV.filter((k) => !process.env[k]);\nif (missing.length) {\n  throw new Error(\n    `Missing required env vars for seed: ${missing.join(', ')} (loaded ${process.env.ENV_FILE ?? '.env.local'})`,\n  );\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `setup-dev-env.sh` before the seed so env files are populated.","Maintain an explicit REQUIRED list at the top of the seed script and validate it first.","Keep `.env.example` as the source of truth for required keys.","Pass `ENV_FILE` explicitly per environment."],"tags":["env","configuration","script","seed","partners"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}