hcengineering/platform · error

process.error.RequiredParamsNotProvided

process.error.RequiredParamsNotProvided

Error message

RequiredParamsNotProvided: association

What it means

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.

Source

Thrown at server-plugins/process-resources/src/functions.ts:266

    card = hierarchy.as(card, _process.masterTag)
  }

  return attributes.every(([key, attr]) => isRequiredValueFilled(getObjectValue(key, card), attr))
}

export function CheckTime (control: ProcessControl, execution: Execution, params: Record<string, any>): boolean {
  if (params.value === undefined) return false
  return params.value <= Date.now()
}

export async function AddRelation (
  params: MethodParams<Relation>,
  execution: Execution,
  control: ProcessControl
): Promise<ExecuteResult> {
  const association = params.association as Ref<Association>
  if (isEmpty(association)) {
    throw processError(process.error.RequiredParamsNotProvided, { params: 'association' })
  }
  if (isEmpty(params._id)) {
    throw processError(process.error.RequiredParamsNotProvided, { params: '_id' })
  }
  if (isEmpty(params.direction)) {
    throw processError(process.error.RequiredParamsNotProvided, { params: 'direction' })
  }
  const targetIds = Array.isArray(params._id) ? params._id : [params._id]
  const direction = params.direction as 'A' | 'B'
  const res: Tx[] = []
  const rollback: Tx[] = []
  const context: SuccessExecutionContext[] = []
  for (const targetId of targetIds) {
    const docA = direction === 'A' ? targetId : execution.card
    const docB = direction === 'A' ? execution.card : targetId
    const data: Data<Relation> = {
      association,
      docA,

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Add the association field to params: pass a valid Ref<Association> value pointing at the association object you want to link objects with.
  2. 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.
  3. Confirm the association object actually exists (control.client.getModel().findObject(associationId)) so you are not propagating an empty value from a failed fetch.
  4. Check the method signature/documentation for AddRelation to ensure required params are association, _id and direction, and that none were renamed.

Example fix

// before
await process(AddRelation, { _id: targetId, direction: 'A' })
// after
await process(AddRelation, { association: association._id, _id: targetId, direction: 'A' })
Defensive patterns

Strategy: validation

Validate before calling

import { isEmpty } from 'fast-equals' // or your utils
if (isEmpty(associationId)) {
  throw new Error('AddRelation requires a non-empty association ref')
}
await process(AddRelation, { association: associationId, _id: targetId, direction: 'A' })

Type guard

function hasAssociation(p: unknown): p is { association: Ref<Association> } {
  return typeof p === 'object' && p !== null &&
    'association' in p && (p as any).association !== undefined && (p as any).association !== null && (p as any).association !== ''
}

Try / catch

try {
  await process(AddRelation, params)
} catch (err: any) {
  if (err?.code === 'process.error.RequiredParamsNotProvided' && err?.params === 'association') {
    console.error('AddRelation called without association; fix params', params)
    return
  }
  throw err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/792b4af736c92aec. Report an issue: GitHub.