{"record":{"id":"3f862a3f00a3160e","repo":"remotion-dev/remotion","slug":"region-parameter-must-be-a-string-but-is-json","errorCode":null,"errorMessage":"\"region\" parameter must be a string, but is ${JSON.stringify(region)}","messagePattern":"\"region\" parameter must be a string, but is (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/cloudrun/src/shared/validate-region.ts","lineNumber":6,"sourceCode":"import type {GcpRegion} from '../pricing/gcp-regions';\nimport {GCP_REGIONS} from '../pricing/gcp-regions';\n\nexport const validateRegion = (region: unknown) => {\n\tif (typeof region !== 'string') {\n\t\tthrow new TypeError(\n\t\t\t`\"region\" parameter must be a string, but is ${JSON.stringify(region)}`,\n\t\t);\n\t}\n\n\t// check region is part of GCP_REGIONS list\n\tif (!GCP_REGIONS.includes(region as GcpRegion)) {\n\t\tthrow new TypeError(\n\t\t\t`\"region\" parameter must be one of ${GCP_REGIONS.join(\n\t\t\t\t', ',\n\t\t\t)}, but is ${JSON.stringify(region)}`,\n\t\t);\n\t}\n\n\treturn region as GcpRegion;\n};\n","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/cloudrun/src/shared/validate-region.ts#L1-L22","documentation":"Thrown by validateRegion() when the region argument is not a string. This is the type guard before the GCP_REGIONS membership check. Region is required for nearly every Cloud Run API to address resources in the correct Google Cloud location.","triggerScenarios":"Passing a non-string region (undefined, null, number, object) to any Cloud Run API that validates region.","commonSituations":"Region read from an unset env var; passing a config object instead of its region string property; destructuring typo leaving region undefined.","solutions":["Pass a valid GCP region string such as 'us-east1'.","Default region when unset: const region = config.region ?? 'us-east1' (the package DEFAULT_REGION).","Validate config at startup."],"exampleFix":"// before\nconst { REGION } = process.env; // undefined\nawait deployService({ region: REGION, ... });\n// after\nconst region = process.env.REGION ?? 'us-east1';\nawait deployService({ region, ... });","handlingStrategy":"type-guard","validationCode":"import { validateRegion } from '@remotion/cloudrun/shared';\nvalidateRegion(region);","typeGuard":"function isRegionString(v: unknown): v is string {\n  return typeof v === 'string';\n}","tryCatchPattern":"const region = typeof inputRegion === 'string' ? inputRegion : 'us-east1';","preventionTips":["Default region to 'us-east1' (the package default) when unset.","Type your config so region is always a string.","Assert env vars are set at process start."],"tags":["cloudrun","validation","typescript","region","gcp"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}