hcengineering/platform · error

process.error.ObjectNotFound

process.error.ObjectNotFound

Error message

ObjectNotFound: ${execution.card}

What it means

UpdateCard looks up the card being executed (execution.card) in control.cache and throws ObjectNotFound when it is undefined — the object the process execution is attached to could not be resolved. This is thrown before any update transaction is built, so execution aborts.

Source

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

      if (max !== undefined && res > max) res = max
      if (digits !== undefined) {
        return Number(Number(res).toFixed(digits))
      }
      return res
    }
    default:
      return value
  }
}

export async function UpdateCard (
  params: MethodParams<Card>,
  execution: Execution,
  control: ProcessControl
): Promise<ExecuteResult> {
  if (Object.keys(params).length === 0) throw processError(process.error.RequiredParamsNotProvided, { params: 'ANY' })
  const target = control.cache.get(execution.card)
  if (target === undefined) throw processError(process.error.ObjectNotFound, { _id: execution.card })
  const hierarchy = control.client.getHierarchy()
  const _process = control.client.getModel().findObject(execution.process)
  if (_process === undefined) throw processError(process.error.ObjectNotFound, { _id: execution.process })
  const update: Record<string, any> = {}
  const prevValue: Record<string, any> = {}
  for (const key in params) {
    const realKey = resolveAttributeId(_process, key)
    const prevKey = checkMixinKey(realKey, _process.masterTag, hierarchy)
    prevValue[realKey] = getObjectValue(prevKey, target)
    const attr = hierarchy.findAttribute(_process.masterTag, realKey)
    if (attr === undefined) {
      update[realKey] = (params as any)[key]
    } else {
      update[realKey] = respectAttributeType(attr.type, (params as any)[key])
    }
  }

  const res: Tx[] = []

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Verify execution.card refers to an existing card: fetch it via the hierarchy/client (findOne by _id) before running the process, and delete/clean orphaned Execution records.
  2. Fix the workflow/data that created the Execution with a bad card id (e.g. ensure the card is created before the process is started on it).
  3. If the card may legitimately disappear, wrap the process execution in a try/catch for process.error.ObjectNotFound and cancel/skip the execution gracefully.
  4. Check cache population logic if you run UpdateCard with a custom control.cache — ensure the card is loaded before execution.

Example fix

// before
await process(UpdateCard, patch) // execution.card may be stale
// after
const card = await client.findOne(core.class.Doc, { _id: execution.card })
if (card === undefined) {
  await cancelExecution(execution) // card no longer exists
  return
}
await process(UpdateCard, patch)
Defensive patterns

Strategy: try-catch

Validate before calling

const card = await client.findOne(core.class.Doc, { _id: execution.card })
if (card === undefined) {
  await cancelExecution(execution) // card gone; do not run UpdateCard
  return
}

Type guard

async function cardExists(client: Client, id: Ref<Doc> | undefined): id is Ref<Doc> {
  if (id === undefined) return false
  return (await client.findOne(core.class.Doc, { _id: id })) !== undefined
}

Try / catch

try {
  await process(UpdateCard, params)
} catch (err: any) {
  if (err?.code === 'process.error.ObjectNotFound' && err?._id === execution.card) {
    await cancelExecution(execution) // stale card; retrying will not help
    return
  }
  throw err
}

Prevention

When it happens

Trigger: Running an UpdateCard process execution whose execution.card references a card that does not exist (deleted, wrong space, wrong id in the Execution object), or when the cache was not populated for that card.

Common situations: The card was deleted after the process/advisor started but the execution still fires; a copy/import created Execution objects pointing at stale ids; test fixtures using fabricated card ids; migration scripts referencing cards from another instance.

Related errors


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