{"record":{"id":"8c86605bd026f4ef","repo":"hcengineering/platform","slug":"invalid-region-passed-to-migrate-operation","errorCode":null,"errorMessage":"Invalid region passed to migrate operation","messagePattern":"Invalid region passed to migrate operation","errorType":"exception","errorClass":"PlatformError","httpStatus":null,"severity":"error","filePath":"server/account/src/serviceOperations.ts","lineNumber":194,"sourceCode":"        break\n      case 'unarchive':\n        if (event === 'unarchive') {\n          if (workspace.status.mode !== 'archived') {\n            throw new PlatformError(unknownError('Unarchive allowed only for archived workspaces'))\n          }\n        }\n\n        update.mode = 'pending-restore'\n        update.processingAttempts = 0\n        update.processingProgress = 0\n        update.lastProcessingTime = Date.now() - processingTimeoutMs // To not wait for next step\n        break\n      case 'migrate-to': {\n        if (!isActiveMode(workspace.status.mode)) {\n          return false\n        }\n        if (params.length !== 1 && params[0] == null) {\n          throw new PlatformError(unknownError('Invalid region passed to migrate operation'))\n        }\n        const regions = getRegions()\n        if (regions.find((it) => it.region === params[0]) === undefined) {\n          throw new PlatformError(unknownError('Invalid region passed to migrate operation'))\n        }\n        if ((workspace.region ?? '') === params[0]) {\n          throw new PlatformError(unknownError('Invalid region passed to migrate operation'))\n        }\n\n        update.mode = 'migration-pending-backup'\n        // NOTE: will only work for Mongo accounts\n        update.targetRegion = params[0]\n        update.processingAttempts = 0\n        update.processingProgress = 0\n        update.lastProcessingTime = Date.now() - processingTimeoutMs // To not wait for next step\n        break\n      }\n      default:","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/server/account/src/serviceOperations.ts#L176-L212","documentation":"This error is thrown in the 'migrate-to' branch of performWorkspaceOperation when the params array does not contain a usable region value: the check `params.length !== 1 && params[0] == null` fires when params is malformed or the first param is null. Note the check uses AND, so it only throws on the malformed-params case here. The migration target region must be supplied as exactly one non-null param.","triggerScenarios":"Calling the 'migrate-to' workspace operation with params that are empty, longer than 1, or whose first element is null/undefined — e.g. the caller omitted the target region argument or passed a null placeholder.","commonSituations":"Service-to-service calls where the region parameter was dropped or serialized as null; scripts built for an older API shape that did not take a region; copying example code without filling in the target region.","solutions":["Pass exactly one non-null region string in params, e.g. ['us-west-2']","Verify the caller serializes params as an array with a single string element, not null or empty","Confirm the region also exists in getRegions() to avoid the closely-related validation error at line 198"],"exampleFix":"// before\nawait performWorkspaceOperation(ctx, db, 'migrate-to', workspaceUuid, [])\n// after\nawait performWorkspaceOperation(ctx, db, 'migrate-to', workspaceUuid, ['us-west-2'])","handlingStrategy":"validation","validationCode":"function validateMigrateParams(params: unknown[]): string | null {\n  if (Array.isArray(params) && params.length === 1 && typeof params[0] === 'string' && params[0].length > 0) {\n    return params[0]\n  }\n  throw new Error('migrate-to requires exactly one non-empty region string')\n}","typeGuard":"function isValidMigrateParams(p: unknown): p is [string] {\n  return Array.isArray(p) && p.length === 1 && typeof p[0] === 'string' && p[0] !== ''\n}","tryCatchPattern":"try {\n  await performWorkspaceOperation(ctx, db, 'migrate-to', workspaceUuid, [region])\n} catch (err) {\n  if (err instanceof PlatformError && err.message.includes('Invalid region passed to migrate operation')) {\n    // inspect params shape: wrong arity or null region\n  } else throw err\n}","preventionTips":["Always pass params as a single-element array containing the region string","Validate region is a non-empty string at the call site","Share a single typed helper for building migrate-to params across services"],"tags":["workspace","migration","invalid-params"],"backgroundTag":"invalid-migration-region","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}