{"record":{"id":"e94079e8152b1050","repo":"prestodb/presto","slug":"invalid-encryption-materials-provider-class","errorCode":null,"errorMessage":"Invalid encryption materials provider class: ","messagePattern":"Invalid encryption materials provider class: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java","lineNumber":838,"sourceCode":"        return clientBuilder.build();\n    }\n\n    private static Optional<EncryptionMaterialsProvider> createEncryptionMaterialsProvider(Configuration hadoopConfig)\n    {\n        String kmsKeyId = hadoopConfig.get(S3_KMS_KEY_ID);\n        if (kmsKeyId != null) {\n            return Optional.of(new KMSEncryptionMaterialsProvider(kmsKeyId));\n        }\n\n        String empClassName = hadoopConfig.get(S3_ENCRYPTION_MATERIALS_PROVIDER);\n        if (empClassName == null) {\n            return Optional.empty();\n        }\n\n        try {\n            Object instance = Class.forName(empClassName).getConstructor().newInstance();\n            if (!(instance instanceof EncryptionMaterialsProvider)) {\n                throw new RuntimeException(\"Invalid encryption materials provider class: \" + instance.getClass().getName());\n            }\n            EncryptionMaterialsProvider emp = (EncryptionMaterialsProvider) instance;\n            if (emp instanceof Configurable) {\n                ((Configurable) emp).setConf(hadoopConfig);\n            }\n            return Optional.of(emp);\n        }\n        catch (ReflectiveOperationException e) {\n            throw new RuntimeException(\"Unable to load or create S3 encryption materials provider: \" + empClassName, e);\n        }\n    }\n\n    private AWSCredentialsProvider createAwsCredentialsProvider(URI uri, Configuration conf)\n    {\n        Optional<AWSCredentials> credentials = getAwsCredentials(uri, conf);\n        if (credentials.isPresent()) {\n            return new AWSStaticCredentialsProvider(credentials.get());\n        }","sourceCodeStart":820,"sourceCodeEnd":856,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java#L820-L856","documentation":"When hive.s3.encryption-materials-provider names a class, the connector loads it reflectively and requires it to implement com.amazonaws.services.s3.model.EncryptionMaterialsProvider. A class that instantiates but does not implement that interface triggers this RuntimeException.","triggerScenarios":"Setting s3.encryption-materials-provider to a class that implements a different provider interface (e.g. KMSMaterialsProvider, AWSCredentialsProvider) or a custom class missing the interface.","commonSituations":"Copy-pasted config from another connector; class compiled against different AWS SDK versions where interface moved packages; implementing KMSEncryptionMaterialsProvider without wrapping in a provider.","solutions":["Ensure the configured class implements EncryptionMaterialsProvider and has a no-arg constructor.","Wrap custom key material in a class extending KMSEncryptionMaterialsProvider or implementing the interface directly.","Check the class package against the AWS SDK version bundled with Presto.","Remove the s3.encryption-materials-provider setting if client-side encryption is not needed."],"exampleFix":"// before\npublic class MyMaterials { /* no interface */ }\n// after\npublic class MyMaterials implements EncryptionMaterialsProvider {\n    public MyMaterials() {}\n    @Override public EncryptionMaterials getEncryptionMaterials() { ... }\n    @Override public void refresh() {}\n}","handlingStrategy":"validation","validationCode":"String cls = conf.get(\"hive.s3.encryption-materials-provider\");\nif (cls != null) {\n    Class<?> c = Class.forName(cls);\n    if (!EncryptionMaterialsProvider.class.isAssignableFrom(c)) {\n        throw new IllegalStateException(cls + \" does not implement EncryptionMaterialsProvider\");\n    }\n    c.getDeclaredConstructor(); // must exist and be public\n}","typeGuard":"boolean isValidMaterialsProvider(Class<?> c) {\n    return EncryptionMaterialsProvider.class.isAssignableFrom(c);\n}","tryCatchPattern":"try {\n    createEncryptionMaterialsProvider(...);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Invalid encryption materials provider class:\")) {\n        // fix the configured class to implement EncryptionMaterialsProvider\n    }\n    throw e;\n}","preventionTips":["Implement EncryptionMaterialsProvider (plus no-arg constructor) in custom classes.","Verify interface packages match the AWS SDK version bundled with Presto.","Test provider instantiation in a unit test before deploying config.","Remove the setting when client-side encryption is unused."],"tags":["s3","encryption","configuration","reflection"],"backgroundTag":"invalid-configuration-class","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}