{"record":{"id":"45dadb05ab534a4f","repo":"elastic/elasticsearch","slug":"type-not-found","errorCode":null,"errorMessage":"type [{}] not found","messagePattern":"type \\[(.+?)\\] not found","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/lang-painless/src/main/java/org/elasticsearch/painless/Def.java","lineNumber":491,"sourceCode":"     * Returns an implementation of interfaceClass that calls receiverClass.name\n     * <p>\n     * This is just like LambdaMetaFactory, only with a dynamic type. The interface type is known,\n     * so we simply need to lookup the matching implementation method based on receiver type.\n     */\n    static MethodHandle lookupReference(\n        PainlessLookup painlessLookup,\n        FunctionTable functions,\n        Map<String, Object> constants,\n        MethodHandles.Lookup methodHandlesLookup,\n        String interfaceClass,\n        Class<?> receiverClass,\n        String name,\n        boolean chargesAllocation\n    ) throws Throwable {\n\n        Class<?> interfaceType = painlessLookup.canonicalTypeNameToType(interfaceClass);\n        if (interfaceType == null) {\n            throw new IllegalArgumentException(\"type [\" + interfaceClass + \"] not found\");\n        }\n        PainlessMethod interfaceMethod = painlessLookup.lookupFunctionalInterfacePainlessMethod(interfaceType);\n        if (interfaceMethod == null) {\n            throw new IllegalArgumentException(\"Class [\" + interfaceClass + \"] is not a functional interface\");\n        }\n        int arity = interfaceMethod.typeParameters().size();\n        PainlessMethod implMethod = painlessLookup.lookupRuntimePainlessMethod(receiverClass, name, arity);\n        if (implMethod == null) {\n            throw new IllegalArgumentException(\n                \"dynamic method [\" + typeToCanonicalTypeName(receiverClass) + \", \" + name + \"/\" + arity + \"] not found\"\n            );\n        }\n\n        // Charging def-receiver ref: the script was over-captured (receiver type unknown, so no pre-filter). Charge only if\n        // the resolved target has an estimator; either way lookupReferenceInternal appends the script and drops it.\n        return lookupReferenceInternal(\n            painlessLookup,\n            functions,","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/lang-painless/src/main/java/org/elasticsearch/painless/Def.java#L473-L509","documentation":"Def.lookupReference (lambda reference binding) first resolves the declared functional-interface class name through painlessLookup.canonicalTypeNameToType. If that map has no entry for the given interfaceClass string (the type was never registered/whitelisted), it throws 'type not found' with the unresolved name. This precedes any method resolution and indicates the interface type itself is unknown to the Painless type system.","triggerScenarios":"A Painless script uses a method-reference or lambda whose declared interface type is not registered in the Painless allowlist — e.g. referencing a custom or non-whitelisted functional interface (java.util.function.X from a non-JDK package, or a JDK functional interface excluded by the allowlist).","commonSituations":"Plugin code expecting a custom functional interface to be available. Using a functional interface added in a newer JDK than the allowlist covers. Typo in the interface canonical name.","solutions":["Use a standard whitelisted functional interface from java.util.function (Function, Consumer, Predicate, etc.) that Painless knows about.","Verify the exact canonical name spelling matches a registered type.","If a custom interface is required, register it in the painless allowlist via a plugin."],"exampleFix":"// before\n// references a non-whitelisted interface type\n// after\n// use java.util.function.Function which is whitelisted","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Restrict lambda targets to whitelisted java.util.function types in script authoring tooling.\n// Maintain an allow-set: [Function, Consumer, Predicate, Supplier, BiFunction, ...]","tryCatchPattern":"// On ScriptException matching 'type [...] not found', tell the author the interface is not whitelisted and suggest a standard functional interface.","preventionTips":["Use only java.util.function functional interfaces for Painless lambdas.","Do not reference custom interfaces unless registered via a plugin allowlist.","Lint script authoring to flag non-standard interface references."],"tags":["painless","script","dynamic-dispatch","def","lambda","type-resolution"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}