hcengineering/platform · error · ProcessError

process.error.MethodNotFound

process.error.MethodNotFound

Error message

Method not found: {methodId}

What it means

Thrown by fillValue when a context function references an object (func.func) that findObject cannot resolve — the transform/method object does not exist in the model. Message includes the missing methodId.

Source

Thrown at server-plugins/process-resources/src/utils.ts:117

        {},
        { attr: attr?.label ?? getEmbeddedLabel(context.key) }
      )
    }
    return val
  } else {
    throw processError(process.error.ObjectNotFound, { _id: execution.card }, {}, true)
  }
}

async function fillValue (
  value: any,
  context: SelectedContext,
  control: ProcessControl,
  execution: Execution
): Promise<any> {
  for (const func of context.functions ?? []) {
    const transform = control.client.getModel().findObject(func.func)
    if (transform === undefined) throw processError(process.error.MethodNotFound, { methodId: func.func }, {}, true)
    if (!control.client.getHierarchy().hasMixin(transform, serverProcess.mixin.FuncImpl)) {
      throw processError(process.error.MethodNotFound, { methodId: func.func }, {}, true)
    }
    const funcImpl = control.client.getHierarchy().as(transform, serverProcess.mixin.FuncImpl)
    const f = await getResource(funcImpl.func)
    value = await f(value, func.props, control, execution)
  }
  return value
}

async function getNestedValue (control: ProcessControl, execution: Execution, context: SelectedNested): Promise<any> {
  const card = control.cache.get(execution.card)
  if (card === undefined) throw processError(process.error.ObjectNotFound, { _id: execution.card }, {}, true)
  const _process = control.client.getModel().findObject(execution.process)
  if (_process === undefined) throw processError(process.error.ObjectNotFound, { _id: execution.process })
  const realPath = resolveAttributeId(_process, context.path)
  const attr = control.client.getHierarchy().findAttribute(card._class, realPath)
  if (attr === undefined) throw processError(process.error.AttributeNotExists, { key: realPath })

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Look up the methodId in the model; recreate the missing function object or fix the reference.
  2. Re-export/import the full template including all function objects so ids resolve.
  3. Remove or update the stale entry in context.functions.
  4. Add preflight validation of context.functions against the model before running the process step.

Example fix

// before: blind iteration
for (const func of context.functions ?? []) { ... }
// after: validate first
const missing = (context.functions ?? []).filter(f => control.client.getModel().findObject(f.func) === undefined)
if (missing.length > 0) throw new Error('Unknown functions: ' + missing.map(f => f.func).join(', '))
Defensive patterns

Strategy: validation

Validate before calling

const missing = (context.functions ?? [])
  .map(f => f.func)
  .filter(id => control.client.getModel().findObject(id) === undefined)
if (missing.length > 0) throw new Error('Unknown function ids: ' + missing.join(', '))

Type guard

function isKnownFunction(control: ProcessControl, id: Ref<Doc>): boolean {
  return control.client.getModel().findObject(id) !== undefined
}

Try / catch

try {
  const value = await getContextValue(ctx, control, execution)
} catch (err) {
  if ((err as Error).message.startsWith('Method not found')) {
    // strip stale function from context.functions and retry
  } else throw err
}

Prevention

When it happens

Trigger: getContextValue → fillValue iterating context.functions where a function's func id points to a deleted or never-created object in the model.

Common situations: Process templates referencing functions removed during refactors/migrations; importing templates between workspaces where function objects were not exported; typo'd or stale object ids stored in context.functions.

Related errors


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