{"record":{"id":"a0e4e00f727927b8","repo":"twentyhq/twenty","slug":"missing-env-var-name","errorCode":null,"errorMessage":"Missing env var: ${name}","messagePattern":"Missing env var: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-apps/internal/twenty-partners/src/scripts/configure-partner-rls.ts","lineNumber":31,"sourceCode":"//    upsertFieldPermissions rejects out-of-band changes to app-owned roles\n//    (ROLE_BELONGS_TO_ANOTHER_APPLICATION), so those must come from the manifest; if any\n//    expected lock is missing, the script exits non-zero and tells you to re-sync.\n//\n// 3. Verifies Application field permissions the same way (pitch editable; rest locked).\n//\n// Usage:\n//   yarn rls:configure          # against .env.local\n//   yarn rls:configure:prod     # against .env.prod\n\nimport { config } from 'dotenv';\nconfig({ path: process.env.ENV_FILE ?? '.env.local' });\n\nimport { PARTNER_ROLE_UNIVERSAL_IDENTIFIER } from 'src/constants/universal-identifiers';\nimport { PARTNER_ROLE_LABEL } from 'src/roles/partner.role';\n\nconst requireEnv = (name: string): string => {\n  const value = process.env[name];\n  if (!value) throw new Error(`Missing env var: ${name}`);\n  return value;\n};\n\nconst SIMPLE_TARGET_OBJECTS = [\n  'partner',\n  'person',\n  'company',\n  'partnerLink',\n  'partnerService',\n  'partnerContent',\n  'application',\n] as const;\ntype SimpleTargetObject = (typeof SIMPLE_TARGET_OBJECTS)[number];\n\n// opportunity uses an OR group (handled separately), but still needs an existence check.\nconst ALL_TARGET_OBJECTS = [...SIMPLE_TARGET_OBJECTS, 'opportunity'] as const;\n\n// Stable id for the OR predicate group — re-runs upsert in place instead of creating","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-apps/internal/twenty-partners/src/scripts/configure-partner-rls.ts#L13-L49","documentation":"configure-partner-rls's requireEnv throws when a needed environment variable is empty/unset. The script loads .env.local (or ENV_FILE) via dotenv before this runs, so the var must be present in that file or the real environment. The known required vars are TWENTY_PARTNERS_API_URL and TWENTY_PARTNERS_API_KEY (plus any others requireEnv is later extended to read).","triggerScenarios":"requireEnv('TWENTY_PARTNERS_API_URL') or requireEnv('TWENTY_PARTNERS_API_KEY') reads an undefined/empty-string value. Happens when .env.local (or the ENV_FILE target) is missing, incomplete, or ENV_FILE points at a non-existent path so dotenv silently loads nothing.","commonSituations":"Fresh clone without copying .env.example to .env.local; running yarn rls:configure before populating secrets; pointing ENV_FILE at the wrong file; running rls:configure:prod against a .env.prod that lacks the key.","solutions":["Ensure .env.local (or .env.prod for :prod) defines TWENTY_PARTNERS_API_URL and TWENTY_PARTNERS_API_KEY.","If using a non-default env file, run with ENV_FILE=./path/to/.env yarn rls:configure and confirm the path exists.","Copy and fill the provided .env.example template for the target environment.","Verify dotenv actually loaded the file (no typo in the path passed to config())."],"exampleFix":"# before — .env.local missing or incomplete\n\n# after — populate the required vars\nTWENTY_PARTNERS_API_URL=https://your-workspace.twenty.app\nTWENTY_PARTNERS_API_KEY=your-metadata-api-key","handlingStrategy":"validation","validationCode":"import { config } from 'dotenv';\nconfig({ path: process.env.ENV_FILE ?? '.env.local' });\n\nconst REQUIRED = ['TWENTY_PARTNERS_API_URL', 'TWENTY_PARTNERS_API_KEY'] as const;\nconst missing = REQUIRED.filter((k) => !process.env[k]);\nif (missing.length > 0) {\n  throw new Error(`Missing env vars in ${process.env.ENV_FILE ?? '.env.local'}: ${missing.join(', ')}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a committed .env.example listing every var the scripts need; copy it to .env.local/.env.prod.","Run a preflight env check before the script body so all missing vars are reported at once.","For prod, confirm .env.prod exists and is complete before yarn rls:configure:prod.","If using ENV_FILE, verify the path resolves before invoking dotenv."],"tags":["env","config","cli","rls","partners"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}