{"record":{"id":"e9e6281e915b2cce","repo":"n8n-io/n8n","slug":"functionname-is-only-callable-on-types-type","errorCode":null,"errorMessage":"${functionName}() is only callable on types ${typeNames}","messagePattern":"(.+?)\\(\\) is only callable on types (.+?)","errorType":"exception","errorClass":"ExpressionExtensionError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/expression-runtime/src/extensions/extend.ts","lineNumber":155,"sourceCode":" */\nexport function extend(input: unknown, functionName: string, args: unknown[]) {\n\tconst foundFunction = findExtendedFunction(input, functionName);\n\n\t// No type specific or generic function found. Check to see if\n\t// any types have a function with that name. Then throw an error\n\t// letting the user know the available types.\n\tif (!foundFunction) {\n\t\tcheckIfValueDefinedOrThrow(input, functionName);\n\t\tconst haveFunction = EXTENSION_OBJECTS.filter((v) => functionName in v.functions);\n\t\tif (!haveFunction.length) {\n\t\t\t// This shouldn't really be possible but we should cover it anyway\n\t\t\tthrow new ExpressionExtensionError(`Unknown expression function: ${functionName}`);\n\t\t}\n\n\t\tif (haveFunction.length > 1) {\n\t\t\tconst lastType = `\"${haveFunction.pop()!.typeName}\"`;\n\t\t\tconst typeNames = `${haveFunction.map((v) => `\"${v.typeName}\"`).join(', ')}, and ${lastType}`;\n\t\t\tthrow new ExpressionExtensionError(\n\t\t\t\t`${functionName}() is only callable on types ${typeNames}`,\n\t\t\t);\n\t\t} else {\n\t\t\tthrow new ExpressionExtensionError(\n\t\t\t\t`${functionName}() is only callable on type \"${haveFunction[0].typeName}\"`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (foundFunction.type === 'native') {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn foundFunction.function.apply(input, args);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn foundFunction.function(input, args);\n}\n","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/expression-runtime/src/extensions/extend.ts#L137-L173","documentation":"When the requested method name exists on MORE THAN ONE extension type but the input's own type does not provide it, n8n enumerates the types it IS available on, formatted as `\"A\", \"B\", and \"C\"`. This is the multi-type variant of the dispatch-failure branch.","triggerScenarios":"Calling a method that exists for several types but not for the current value's type — e.g. calling a string/number-shared method on a plain object.","commonSituations":"Type mismatch in the expression; assuming a method works on any value; upstream node returned an unexpected type (object vs primitive).","solutions":["Convert the value to one of the listed types first (`.toString()`, `.toNumber()`, `.toDateTime()`).","Use a method that is actually defined for the current value's type.","Inspect the upstream node output to confirm the runtime type."],"exampleFix":"// before (count is a number, but the method needs a string)\n{{ $json.count.someSharedMethod() }}\n// after\n{{ $json.count.toString().someSharedMethod() }}","handlingStrategy":"type-guard","validationCode":"// Confirm the value's runtime type matches one of the types listed in the error before calling the method:\nconst t = Array.isArray($json.x) ? 'array' : $json.x instanceof Date ? 'date' : typeof $json.x;\nif (!['string','number'].includes(t)) {\n  throw new Error(`Method not available on type: ${t}`);\n}\nreturn $json;","typeGuard":"const isStringOrNumber = (v: unknown): v is string | number =>\n  typeof v === 'string' || typeof v === 'number';","tryCatchPattern":null,"preventionTips":["Coerce values to a listed type before calling shared methods (`.toString()`, `.toNumber()`).","Inspect upstream node output types before writing the expression.","Prefer type-specific methods over shared ones when the type is known."],"tags":["expression","type-mismatch","dispatch"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}