{"record":{"id":"b81a94e0d19af5ec","repo":"prestodb/presto","slug":"unknown-codec-codecname","errorCode":null,"errorMessage":"Unknown codec: ${codecName}","messagePattern":"Unknown codec: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-rcfile/src/main/java/com/facebook/presto/rcfile/HadoopCodecFactory.java","lineNumber":62,"sourceCode":"    }\n\n    private CompressionCodec createCompressionCodec(String codecName)\n    {\n        try {\n            Class<? extends CompressionCodec> codecClass = classLoader.loadClass(codecName).asSubclass(CompressionCodec.class);\n            Constructor<? extends CompressionCodec> constructor = codecClass.getDeclaredConstructor();\n            constructor.setAccessible(true);\n            CompressionCodec codec = constructor.newInstance();\n            if (codec instanceof Configurable) {\n                // Hadoop is crazy... you have to give codecs an empty configuration or they throw NPEs\n                // but you need to make sure the configuration doesn't \"load\" defaults or it spends\n                // forever loading XML with no useful information\n                ((Configurable) codec).setConf(new Configuration(false));\n            }\n            return codec;\n        }\n        catch (ReflectiveOperationException e) {\n            throw new IllegalArgumentException(\"Unknown codec: \" + codecName, e);\n        }\n    }\n}\n","sourceCodeStart":44,"sourceCodeEnd":66,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-rcfile/src/main/java/com/facebook/presto/rcfile/HadoopCodecFactory.java#L44-L66","documentation":"HadoopCodecFactory.createCompressionCodec instantiates a Hadoop compression codec class by reflective name lookup. If the class cannot be loaded/instantiated (ClassNotFoundException, instantiation failure), it throws IllegalArgumentException 'Unknown codec: <name>'. The configured codec name is not resolvable on the classpath.","triggerScenarios":"An RCFile session/table is configured with a compression codec class name (e.g. org.apache.hadoop.io.compress.SnappyCodec or a custom codec) that is missing from the classpath or fails to construct.","commonSituations":"Reading RCFiles compressed with ZSTD/LZO or a vendor codec whose jar is not on the Presto classpath; typo in codec class name; Hadoop version change moving/renaming codec classes.","solutions":["Verify the codec class name spelling and package against your Hadoop version.","Add the jar providing the codec to the Presto plugin/classpath and restart.","Prefer codecs bundled with the deployment (gzip, snappy via aircompressor).","Re-write the file with a supported codec if the original codec is unavailable."],"exampleFix":"// before: unknown codec\nsession.getProperties().put(\"rcfile_compression_codec\", \"org.apache.hadoop.io.compress.ZStandardCodec\");\n// after: supported codec\nsession.getProperties().put(\"rcfile_compression_codec\", \"com.facebook.airlift.compress.zstd.ZstdJniCompressor\"); // or use gzip/snappy","handlingStrategy":"validation","validationCode":"// check the codec class is loadable before opening the file\ntry {\n  Class<?> c = Class.forName(codecClassName);\n  if (!org.apache.hadoop.io.compress.CompressionCodec.class.isAssignableFrom(c))\n    throw new IllegalStateException(codecClassName + \" is not a CompressionCodec\");\n} catch (ClassNotFoundException e) {\n  throw new IllegalStateException(\"Codec not on classpath: \" + codecClassName);\n}","typeGuard":null,"tryCatchPattern":"try {\n  CompressionCodec codec = codecFactory.codec(codecName);\n} catch (IllegalArgumentException e) {\n  if (String.valueOf(e.getMessage()).startsWith(\"Unknown codec:\")) {\n    // fall back to a supported codec or fail fast with a clear config error\n  } else throw e;\n}","preventionTips":["List required codec jars (zstd/lzo/vendor codecs) in deployment provisioning","Validate codec class names in config at startup, not at first file read","Prefer codecs bundled with the runtime (gzip, snappy via aircompressor)","After Hadoop upgrades, smoke-test reading files of each codec in use"],"tags":["classpath","compression","configuration","rcfile"],"backgroundTag":"unknown-codec-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"}