hcengineering/platform · error · ProcessError
process.error.EmptyFunctionResult
process.error.EmptyFunctionResult
Error message
Empty function result {func} What it means
Thrown when the transform function (sourceFunction) returns null/undefined and the primary function is not process.function.EmptyValue (which legitimately allows empty results). A required function chain produced no value.
Source
Thrown at server-plugins/process-resources/src/utils.ts:268
const func = control.client.getModel().findObject(context.func)
if (func === undefined) throw processError(process.error.MethodNotFound, { methodId: context.func }, {}, true)
const impl = control.client.getHierarchy().as(func, serverProcess.mixin.FuncImpl)
if (impl === undefined) throw processError(process.error.MethodNotFound, { methodId: context.func }, {}, true)
const f = await getResource(impl.func)
const res = await f(null, context.props, control, execution)
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 val = await f(res, {}, control, execution)
if (val == null && context.func !== process.function.EmptyValue) {
throw processError(process.error.EmptyFunctionResult, {}, { func: func.label })
}
return val
}
if (res == null && context.func !== process.function.EmptyValue) {
throw processError(process.error.EmptyFunctionResult, {}, { func: func.label })
}
return res
}
function getUserRequestValue (control: ProcessControl, execution: Execution, context: SelectedUserRequest): any {
const userContext = execution.context[context.id]
if (userContext !== undefined) return userContext
const attr = control.client.getHierarchy().findAttribute(context._class, context.key)
throw processError(
process.error.UserRequestedValueNotProvided,
{},
{ attr: attr?.label ?? getEmbeddedLabel(context.key) }
)View on GitHub (pinned to 63e28dc964)
Solutions
- Fix the transform to return a valid value or a sensible default
- Check the primary function's output matches what the transform expects
- Use process.function.EmptyValue as context.func if empty results are acceptable
- Add logging in the transform to see the input res and returned val
Example fix
// before
const val = await f(res, {}, control, execution)
// after
const val = await f(res, {}, control, execution) ?? [] // explicit default instead of null Defensive patterns
Strategy: try-catch
Validate before calling
const val = await transformFn(res, {}, control, execution)
if (val == null) {
throw new Error(`transform returned no value for input ${JSON.stringify(res)}`)
} Type guard
function isDefined<T>(v: T | null | undefined): v is T { return v !== null && v !== undefined } Try / catch
try {
val = await getContextValue(control, execution, context)
} catch (e) {
if (e?.code === 'process.error.EmptyFunctionResult') {
val = [] // or surface a user-facing 'no data' state
} else throw e
} Prevention
- Return defaults instead of null from transform functions
- Use process.function.EmptyValue when empty results are valid
- Log transform inputs/outputs during development to spot null paths
When it happens
Trigger: val = await f(res, {}, control, execution) yields null while context.func !== EmptyValue — the transform filtered out all input or returned nothing for the given input.
Common situations: Transform's filter predicate matches nothing; upstream primary function returned data the transform does not handle; logic bug returning null instead of a default.
Related errors
- process.error.RequiredParamsNotProvided
- process.error.ObjectNotFound
- process.error.ObjectNotFound
- process.error.EmptyAttributeContextValue
- process.error.MethodNotFound
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/a78370cdc521f732.
Report an issue: GitHub.