{"record":{"id":"59ae529c2699895b","repo":"hcengineering/platform","slug":"missing-or-invalid-required-parameter-targetworks","errorCode":null,"errorMessage":"Missing or invalid required parameter: targetWorkspace","messagePattern":"Missing or invalid required parameter: targetWorkspace","errorType":"http","errorClass":"ApiError","httpStatus":400,"severity":"warning","filePath":"services/export/pod-export/src/server.ts","lineNumber":492,"sourceCode":"        }: {\n          targetWorkspace: WorkspaceUuid\n          _class: Ref<Class<Doc>>\n          query?: DocumentQuery<Doc>\n          conflictStrategy?: 'skip' | 'duplicate'\n          includeAttachments?: boolean\n          relations?: RelationPayload\n          objectId?: Ref<Doc>\n          objectSpace?: Ref<Space>\n          fieldMappers?: Record<string, Record<string, any>>\n          skipDeletedObsolete?: boolean\n          exportOnlyEffective?: boolean\n          includeChildren?: boolean\n        } = req.body\n\n        // Validate required parameters\n        if (targetWorkspace == null || typeof targetWorkspace !== 'string') {\n          measureCtx.warn(`Invalid targetWorkspace parameter: ${String(targetWorkspace)}`)\n          throw new ApiError(400, 'Missing or invalid required parameter: targetWorkspace')\n        }\n        if (_class == null || typeof _class !== 'string') {\n          measureCtx.warn(`Invalid _class parameter: ${String(_class)}`)\n          throw new ApiError(400, 'Missing or invalid required parameter: _class')\n        }\n        if (conflictStrategy !== undefined && conflictStrategy !== 'skip' && conflictStrategy !== 'duplicate') {\n          measureCtx.warn(`Invalid conflictStrategy: ${String(conflictStrategy)}`)\n          throw new ApiError(400, 'Invalid conflictStrategy. Must be \"skip\" or \"duplicate\"')\n        }\n        if (includeAttachments !== undefined && typeof includeAttachments !== 'boolean') {\n          measureCtx.warn(`Invalid includeAttachments: ${String(includeAttachments)}`)\n          throw new ApiError(400, 'Invalid includeAttachments. Must be boolean')\n        }\n\n        decodedToken = decodeToken(token)\n        if (decodedToken.extra?.readonly !== undefined) {\n          throw new ApiError(403, 'Forbidden: read-only token')\n        }","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/export/pod-export/src/server.ts#L474-L510","documentation":"The workspace import/transfer endpoint requires targetWorkspace in the request body to be a non-null string identifying the destination workspace. When it is missing or not a string, the handler logs a warning via measureCtx.warn and throws this 400 before validating _class or other options.","triggerScenarios":"Posting to the transfer route with body lacking targetWorkspace, targetWorkspace: null, or a non-string like a number/object workspace id.","commonSituations":"Sending a workspace UUID object ({ uuid }) instead of the string id; omitting the field because a different endpoint didn't require it; body not JSON-parsed so fields are undefined.","solutions":["Pass targetWorkspace as a plain string workspace identifier in the body.","Confirm the destination workspace id via the account service login info before calling.","Ensure the body is sent as JSON with Content-Type: application/json."],"exampleFix":"// before\n{ \"targetWorkspace\": { \"uuid\": \"abc\" }, \"_class\": \"contact:Person\" }\n// after\n{ \"targetWorkspace\": \"abc-workspace-id\", \"_class\": \"contact:Person\" }","handlingStrategy":"validation","validationCode":"if (typeof body.targetWorkspace !== 'string' || body.targetWorkspace.length === 0) {\n  throw new Error('transfer requires targetWorkspace as a string workspace id')\n}","typeGuard":"function hasTargetWorkspace(b: unknown): b is { targetWorkspace: string } {\n  return typeof (b as any)?.targetWorkspace === 'string'\n}","tryCatchPattern":"try {\n  await transferWorkspace(payload)\n} catch (e) {\n  if (e instanceof ApiError && e.status === 400 && e.message.includes('targetWorkspace')) {\n    console.error('targetWorkspace must be a string workspace id, got:', payload.targetWorkspace)\n  }\n  throw e\n}","preventionTips":["Resolve the destination workspace to a string id before calling; never send objects or numbers.","Centralize transfer request construction in one typed function.","Add an integration test asserting the transfer payload shape."],"tags":["validation","http-400","missing-parameter","target-workspace"],"backgroundTag":"missing-required-parameter","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}