hcengineering/platform · error · ProcessError
process.error.RelatedObjectNotFound
process.error.RelatedObjectNotFound
Error message
Related object not f ound: {attr} What it means
Thrown by getNestedValue after findAll on the referenced target class returns no documents — the nested attribute's referenced objects cannot be found. Message carries the attribute label.
Source
Thrown at server-plugins/process-resources/src/utils.ts:144
}
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 })
const nestedValue = getValue(control, execution, context.path, card)
if (nestedValue === undefined) throw processError(process.error.EmptyAttributeContextValue, {}, { attr: attr.label })
const parentType = attr.type._class === core.class.ArrOf ? (attr.type as ArrOf<Doc>).of : attr.type
const targetClass = parentType._class === core.class.RefTo ? (parentType as RefTo<Doc>).to : parentType._class
const refs = Array.isArray(nestedValue) ? nestedValue : [nestedValue]
const target = await control.client.findAll(targetClass, {
_id: { $in: refs }
})
if (target.length === 0) throw processError(process.error.RelatedObjectNotFound, {}, { attr: attr.label })
const realKey = resolveAttributeId(_process, context.key)
const nested = control.client.getHierarchy().findAttribute(targetClass, realKey)
if (context.sourceFunction !== undefined) {
const transform = control.client.getModel().findObject(context.sourceFunction.func)
if (transform === undefined) {
throw processError(process.error.MethodNotFound, { methodId: context.sourceFunction.func }, {}, true)
}
if (!control.client.getHierarchy().hasMixin(transform, serverProcess.mixin.FuncImpl)) {
throw processError(process.error.MethodNotFound, { methodId: context.sourceFunction.func }, {}, true)
}
const funcImpl = control.client.getHierarchy().as(transform, serverProcess.mixin.FuncImpl)
const f = await getResource(funcImpl.func)
const reduced = await f(target, {}, control, execution)
const val = Array.isArray(reduced)
? reduced.map((v) => getValue(control, execution, context.key, v))
: getValue(control, execution, context.key, reduced)
if (val == null) {
throw processError(View on GitHub (pinned to 63e28dc964)
Solutions
- Check the referenced _ids exist and are visible to the current client (query findAll manually with the same ids).
- Repair or clear dangling references on the card; re-link to existing objects.
- Check space/permission filters in findAll that may hide valid targets.
- Add referential integrity checks before deleting objects that are referenced by process executions.
Example fix
// before
const nested = await getNestedValue(control, execution, ctx)
// after: verify references resolve
const refs = Array.isArray(card[ctx.path]) ? card[ctx.path] : [card[ctx.path]]
const found = await control.client.findAll(targetClass, { _id: { $in: refs } })
if (found.length === 0) throw new Error('Referenced objects missing for ' + ctx.path)
const nested = await getNestedValue(control, execution, ctx) Defensive patterns
Strategy: validation
Validate before calling
const refs = Array.isArray(card[context.path]) ? card[context.path] : [card[context.path]]
const found = await control.client.findAll(targetClass, { _id: { $in: refs } })
if (found.length === 0) throw new Error('Referenced objects missing') Type guard
async function refsResolve(client: Client, targetClass: Ref<Class<Doc>>, refs: Ref<Doc>[]): Promise<boolean> {
return (await client.findAll(targetClass, { _id: { $in: refs }, limit: 1 })).length > 0
} Try / catch
try {
const value = await getNestedValue(control, execution, ctx)
} catch (err) {
if ((err as Error).message.startsWith('Related object not found')) {
// repair dangling references or re-link
} else throw err
} Prevention
- Enforce referential integrity before deleting referenced objects
- Check space/permission visibility of referenced docs
- Clean dangling references after imports/restores
- Periodically audit reference attributes for dead links
When it happens
Trigger: getNestedValue resolving a RefTo/ArrOf reference attribute whose _id(s) are passed to control.client.findAll, but zero matching documents are returned: references were deleted, ids are stale, or permissions/space filters exclude them.
Common situations: Referenced objects deleted (or moved to another space) after being linked; cross-workspace imports with dangling references; security/visibility filters hiding the referenced docs from the current client.
Related errors
- process.error.MethodNotFound
- process.error.RequiredParamsNotProvided
- process.error.ObjectNotFound
- process.error.ObjectNotFound
- process.error.EmptyAttributeContextValue
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/f89bc6542832513c.
Report an issue: GitHub.