{"record":{"id":"792b4af736c92aec","repo":"hcengineering/platform","slug":"process-error-requiredparamsnotprovided","errorCode":"process.error.RequiredParamsNotProvided","errorMessage":"RequiredParamsNotProvided: association","messagePattern":"RequiredParamsNotProvided: association","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server-plugins/process-resources/src/functions.ts","lineNumber":266,"sourceCode":"    card = hierarchy.as(card, _process.masterTag)\n  }\n\n  return attributes.every(([key, attr]) => isRequiredValueFilled(getObjectValue(key, card), attr))\n}\n\nexport function CheckTime (control: ProcessControl, execution: Execution, params: Record<string, any>): boolean {\n  if (params.value === undefined) return false\n  return params.value <= Date.now()\n}\n\nexport async function AddRelation (\n  params: MethodParams<Relation>,\n  execution: Execution,\n  control: ProcessControl\n): Promise<ExecuteResult> {\n  const association = params.association as Ref<Association>\n  if (isEmpty(association)) {\n    throw processError(process.error.RequiredParamsNotProvided, { params: 'association' })\n  }\n  if (isEmpty(params._id)) {\n    throw processError(process.error.RequiredParamsNotProvided, { params: '_id' })\n  }\n  if (isEmpty(params.direction)) {\n    throw processError(process.error.RequiredParamsNotProvided, { params: 'direction' })\n  }\n  const targetIds = Array.isArray(params._id) ? params._id : [params._id]\n  const direction = params.direction as 'A' | 'B'\n  const res: Tx[] = []\n  const rollback: Tx[] = []\n  const context: SuccessExecutionContext[] = []\n  for (const targetId of targetIds) {\n    const docA = direction === 'A' ? targetId : execution.card\n    const docB = direction === 'A' ? execution.card : targetId\n    const data: Data<Relation> = {\n      association,\n      docA,","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/server-plugins/process-resources/src/functions.ts#L248-L284","documentation":"AddRelation validates that the params object passed to the process method contains every field it needs before executing. The 'association' parameter must be a Ref<Association> identifying which association to connect objects with. When it is missing, undefined, null, or an empty value, the library throws process.error.RequiredParamsNotProvided naming the missing parameter.","triggerScenarios":"Calling the AddRelation process method with params that omit the 'association' key, pass association: undefined/null, or pass an empty object/string — e.g. process(method, { _id: targetId, direction: 'A' }) without association.","commonSituations":"Dynamically building the params object where a variable holding the association id is undefined (failed lookup upstream); copying example code that assumed a default association; refactoring that renamed the field (e.g. from 'assoc' or 'attachedTo') without updating the process call.","solutions":["Add the association field to params: pass a valid Ref<Association> value pointing at the association object you want to link objects with.","Verify the variable supplying the association id is populated before invoking the process — log/inspect it; fix the upstream lookup or config that left it undefined.","Confirm the association object actually exists (control.client.getModel().findObject(associationId)) so you are not propagating an empty value from a failed fetch.","Check the method signature/documentation for AddRelation to ensure required params are association, _id and direction, and that none were renamed."],"exampleFix":"// before\nawait process(AddRelation, { _id: targetId, direction: 'A' })\n// after\nawait process(AddRelation, { association: association._id, _id: targetId, direction: 'A' })","handlingStrategy":"validation","validationCode":"import { isEmpty } from 'fast-equals' // or your utils\nif (isEmpty(associationId)) {\n  throw new Error('AddRelation requires a non-empty association ref')\n}\nawait process(AddRelation, { association: associationId, _id: targetId, direction: 'A' })","typeGuard":"function hasAssociation(p: unknown): p is { association: Ref<Association> } {\n  return typeof p === 'object' && p !== null &&\n    'association' in p && (p as any).association !== undefined && (p as any).association !== null && (p as any).association !== ''\n}","tryCatchPattern":"try {\n  await process(AddRelation, params)\n} catch (err: any) {\n  if (err?.code === 'process.error.RequiredParamsNotProvided' && err?.params === 'association') {\n    console.error('AddRelation called without association; fix params', params)\n    return\n  }\n  throw err\n}","preventionTips":["Always construct AddRelation params from a typed builder with association, _id and direction as required fields.","Validate ref params are non-empty before every process call.","Log the full params object on failure to spot renamed/missing keys.","Write a unit test that asserts AddRelation throws for each missing required param, so regressions surface early."],"tags":["process","validation","missing-parameter","api-misuse"],"backgroundTag":"required-params-not-provided","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}