{"record":{"id":"2f28862826a51372","repo":"mastra-ai/mastra","slug":"invalid-region-region-expected-one-of-eu","errorCode":null,"errorMessage":"Invalid --region \"${region}\". Expected one of: eu, us.","messagePattern":"Invalid --region \"(.+?)\"\\. Expected one of: eu, us\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/mastra-factory/src/create.ts","lineNumber":65,"sourceCode":"  orgName: string;\n  project: PlatformProject;\n  secretKey: string;\n  databaseUrl: string;\n}\n\nconst PROJECT_REGION_OPTIONS = [\n  { value: 'eu', label: '🇪🇺 eu' },\n  { value: 'us', label: '🇺🇸 us' },\n] as const satisfies ReadonlyArray<{ value: ProjectRegion; label: string }>;\n\nconst NEON_REGION_BY_PROJECT_REGION = {\n  eu: 'aws-eu-central-1',\n  us: 'aws-us-west-2',\n} as const satisfies Record<ProjectRegion, string>;\n\nfunction parseProjectRegion(region: string): ProjectRegion {\n  if (region === 'eu' || region === 'us') return region;\n  throw new Error(`Invalid --region \"${region}\". Expected one of: eu, us.`);\n}\n\nexport async function create(args: CreateArgs): Promise<void> {\n  p.intro(color.inverse(' Mastra Factory '));\n\n  const requestedRegion = args.region ? parseProjectRegion(args.region) : undefined;\n  const projectName =\n    args.projectName ??\n    (await p.text({\n      message: 'What do you want to name your project?',\n      placeholder: 'my-mastra-factory',\n      validate: value => {\n        if (!value?.trim()) return `Project name can't be empty`;\n        if (fs.existsSync(path.resolve(value.trim()))) return `Directory ${value.trim()} already exists`;\n        return undefined;\n      },\n    }));\n","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/mastra-factory/src/create.ts#L47-L83","documentation":"parseProjectRegion in mastracode/mastra-factory/src/create.ts is the CLI validator for the `--region` flag of `create`. The region must be exactly 'eu' or 'us' (the keys of the REGION_CLUSTER map, typed as ProjectRegion); anything else throws immediately at argument-parse time, before any scaffolding or provisioning happens.","triggerScenarios":"Running the create CLI with --region set to anything other than the exact strings 'eu' or 'us': typos ('eu-west', 'EU', 'us-east-1'), a region copied from an AWS console name, an empty string (--region=\"\"), or a flag value consumed from an env var/ci config holding a legacy value.","commonSituations":"CI pipeline config still referencing an old region identifier after the factory narrowed choices to eu/us; users pasting the AWS cluster name ('aws-eu-central-1') instead of the short alias; case-sensitivity surprises on macOS/Windows shells; documentation examples that predate the eu/us restriction.","solutions":["Use exactly --region eu or --region us (lowercase, no quotes variation).","Map any legacy/verbose region (e.g. 'aws-eu-central-1' → 'eu', 'aws-us-west-2' → 'us') before passing the flag.","Trim/lowercase the value in your wrapper script or CI config before invoking the CLI.","Run the CLI without --region if a default region is acceptable (requestedRegion is only parsed when args.region is set)."],"exampleFix":"// before\npnpm create mastra-factory my-app --region aws-eu-central-1\n// after\npnpm create mastra-factory my-app --region eu","handlingStrategy":"validation","validationCode":"const REGIONS = ['eu', 'us'] as const;\ntype Region = (typeof REGIONS)[number];\nfunction assertRegion(v: string): asserts v is Region {\n  if (!(REGIONS as readonly string[]).includes(v)) throw new Error(`Invalid --region \"${v}\". Expected one of: eu, us.`);\n}","typeGuard":"function isProjectRegion(v: string): v is 'eu' | 'us' {\n  return v === 'eu' || v === 'us';\n}","tryCatchPattern":"// parse-time error; validate before invoking the CLI instead of catching\nlet region: 'eu' | 'us' | undefined;\nif (args.region) {\n  const normalized = args.region.trim().toLowerCase();\n  if (!isProjectRegion(normalized)) {\n    console.error(`Region \"${args.region}\" not supported; use eu or us.`);\n    process.exit(2);\n  }\n  region = normalized;\n}","preventionTips":["Normalize (trim + lowercase) region input from env vars or CI config before passing --region.","Keep a single source of truth for allowed regions in wrapper scripts; don't hardcode legacy AWS cluster names.","Omit --region entirely when the default region is acceptable."],"tags":["cli","argument-validation","configuration"],"backgroundTag":"invalid-argument-value","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}