{"record":{"id":"7247e0bd40023fae","repo":"apache/pulsar","slug":"the-crypto-key-reader-class-s-does-not-exist","errorCode":null,"errorMessage":"The crypto key reader class %s does not exist","messagePattern":"The crypto key reader class (.+?) does not exist","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/ValidatorUtils.java","lineNumber":80,"sourceCode":"            return SchemaType.valueOf(schemaTypeOrClassName.toUpperCase());\n        } catch (IllegalArgumentException e) {\n            // schemaType is not referring to builtin type\n            return null;\n        }\n    }\n\n\n    public static void validateCryptoKeyReader(CryptoConfig conf, TypePool typePool, boolean isProducer) {\n        if (isEmpty(conf.getCryptoKeyReaderClassName())) {\n            return;\n        }\n\n        String cryptoClassName = conf.getCryptoKeyReaderClassName();\n        TypeDescription cryptoClass = null;\n        try {\n            cryptoClass = typePool.describe(cryptoClassName).resolve();\n        } catch (TypePool.Resolution.NoSuchTypeException e) {\n            throw new IllegalArgumentException(\n                    String.format(\"The crypto key reader class %s does not exist\", cryptoClassName));\n        }\n        if (!cryptoClass.asErasure().isAssignableTo(CryptoKeyReader.class)) {\n            throw new IllegalArgumentException(\n                    String.format(\"%s does not implement %s\", cryptoClassName, CryptoKeyReader.class.getName()));\n        }\n\n        boolean hasConstructor = cryptoClass.getDeclaredMethods().stream()\n                .anyMatch(method -> method.isConstructor() && method.getParameters().size() == 1\n                        && method.getParameters().get(0).getType().asErasure().represents(Map.class));\n\n        if (!hasConstructor) {\n            throw new IllegalArgumentException(\n                    String.format(\"The crypto key reader class %s does not implement the desired constructor.\",\n                            conf.getCryptoKeyReaderClassName()));\n        }\n\n        if (isProducer && (conf.getEncryptionKeys() == null || conf.getEncryptionKeys().length == 0)) {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/ValidatorUtils.java#L62-L98","documentation":"validateCryptoKeyReader resolves conf.getCryptoKeyReaderClassName() through a ByteBuddy TypePool; if the named class cannot be found on the classpath (NoSuchTypeException) it throws this IllegalArgumentException. The crypto key reader supplies keys for end-to-end message encryption.","triggerScenarios":"Setting CryptoKeyReaderClassName in ProducerConfig/ConsumerConfig (function crypto conf) to a class absent from the function worker classpath, or a misspelled FQCN.","commonSituations":"Forgot to bundle custom CryptoKeyReader implementation in the function jar; class relocated by shading so the configured name no longer matches; typo when writing the function yaml/CLI flag.","solutions":["Fix the FQCN in cryptoKeyReaderClassName","Package the CryptoKeyReader implementation in the submitted function jar","Avoid shade relocation of the crypto class (keep it outside relocation prefixes) so its name stays stable"],"exampleFix":"// before\n// cryptoKeyReaderClassName: com.acme.shaded.MyKeyReader // relocated name\n// after\n// cryptoKeyReaderClassName: com.acme.MyKeyReader // original, packaged in jar","handlingStrategy":"validation","validationCode":"try {\n    Class.forName(cryptoKeyReaderClassName);\n} catch (ClassNotFoundException e) {\n    throw new IllegalStateException(\"Crypto key reader not in classpath: \" + cryptoKeyReaderClassName);\n}","typeGuard":null,"tryCatchPattern":"try {\n    ValidatorUtils.validateCryptoKeyReader(conf, typePool, isProducer);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().endsWith(\"does not exist\")) {\n        // fix FQCN or bundle the class, then resubmit\n    }\n    throw e;\n}","preventionTips":["Package the CryptoKeyReader implementation in the function jar","Exclude the crypto package from shade relocation","Verify the FQCN via 'jar tf' before submission"],"tags":["pulsar-functions","crypto","class-not-found","bytebuddy"],"backgroundTag":"class-not-found","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}