{"record":{"id":"6a56cb419c3371c9","repo":"apache/flink","slug":"no-parser-available-for-type","errorCode":null,"errorMessage":"No parser available for type '{}'.","messagePattern":"No parser available for type '(.+?)'\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/io/GenericCsvInputFormat.java","lineNumber":318,"sourceCode":"    }\n\n    // --------------------------------------------------------------------------------------------\n    //  Runtime methods\n    // --------------------------------------------------------------------------------------------\n\n    @Override\n    protected void initializeSplit(FileInputSplit split, Long offset) throws IOException {\n        super.initializeSplit(split, offset);\n\n        // instantiate the parsers\n        FieldParser<?>[] parsers = new FieldParser<?>[fieldTypes.length];\n\n        for (int i = 0; i < fieldTypes.length; i++) {\n            if (fieldTypes[i] != null) {\n                Class<? extends FieldParser<?>> parserType =\n                        FieldParser.getParserForType(fieldTypes[i]);\n                if (parserType == null) {\n                    throw new RuntimeException(\n                            \"No parser available for type '\" + fieldTypes[i].getName() + \"'.\");\n                }\n\n                FieldParser<?> p = InstantiationUtil.instantiate(parserType, FieldParser.class);\n\n                p.setCharset(getCharset());\n                if (this.quotedStringParsing) {\n                    if (p instanceof StringParser) {\n                        ((StringParser) p).enableQuotedStringParsing(this.quoteCharacter);\n                    } else if (p instanceof StringValueParser) {\n                        ((StringValueParser) p).enableQuotedStringParsing(this.quoteCharacter);\n                    }\n                }\n\n                parsers[i] = p;\n            }\n        }\n        this.fieldParsers = parsers;","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/io/GenericCsvInputFormat.java#L300-L336","documentation":"Thrown inside GenericCsvInputFormat.initializeSplit when FieldParser.getParserForType(fieldTypes[i]) returns null, meaning the configured field type has no registered CSV parser. Flink's CSV readers only support a fixed set of primitive/wrapper types (Byte, Short, Integer, Long, Float, Double, Boolean, String, BigDecimal, BigInteger, java.sql.Date, java.sql.Time, java.sql.Timestamp). This is a defensive runtime re-check; the same condition is normally caught earlier in setFieldTypesGeneric / setFieldsGeneric with an IllegalArgumentException, so reaching this RuntimeException means fieldTypes was populated without going through the validating setters.","triggerScenarios":"A subclass of GenericCsvInputFormat (or RowCsvInputFormat) assigns this.fieldTypes directly (or via a custom path) with an unsupported Class such as a POJO, Tuple, Map, List, java.util.Date, java.time.LocalDate, or an enum. Then JobManager/TaskManager opens the split and initializeSplit runs getParserForType which returns null.","commonSituations":"Switching from java.util.Date to java.time types after a Java 8 migration; passing a custom value class thinking the CSV reader will call a constructor/fromString method; using a Tuple type field instead of its component types; upgrading Flink where a previously-tolerated type is no longer auto-converted; copy-pasting a Class<?> array from a different reader.","solutions":["Restrict each configured field type to one of the supported parsers: Byte/byte, Short/short, Integer/int, Long/long, Float/float, Double/double, Boolean/boolean, String, BigDecimal, BigInteger, java.sql.Date, java.sql.Time, java.sql.Timestamp.","If you need a richer type, declare the field as String and convert it yourself in the map/function following the source.","Route field type setup through the validated setters (setFieldTypesGeneric / setFieldsGeneric) so an IllegalArgumentException is raised at job-construction time with a clearer message instead of at runtime on the cluster.","Check the unsupported type by calling FieldParser.getParserForType(type) in a unit test before submitting the job."],"exampleFix":"// before\nformat.setFieldTypesGeneric(MyPojo.class, Integer.class);\n// after\nformat.setFieldTypesGeneric(String.class, Integer.class);\n// then map MyPojo from the String field yourself","handlingStrategy":"validation","validationCode":"import org.apache.flink.types.parser.FieldParser;\n\nprivate static void assertAllTypesParsable(Class<?>... fieldTypes) {\n    for (Class<?> t : fieldTypes) {\n        if (t != null && FieldParser.getParserForType(t) == null) {\n            throw new IllegalArgumentException(\n                \"No CSV parser for type \" + t.getName()\n                + \". Supported: primitives/wrappers, String, BigDecimal, BigInteger,\"\n                + \" java.sql.Date/Time/Timestamp.\");\n        }\n    }\n}\n// call in a unit test or job setup before opening the format","typeGuard":"// Restrict the field-type vocabulary at the API boundary\nstatic final Set<Class<?>> CSV_SUPPORTED = Set.of(\n    Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class,\n    Boolean.class, String.class, BigDecimal.class, BigInteger.class,\n    java.sql.Date.class, java.sql.Time.class, java.sql.Timestamp.class);\n\nstatic Class<?> csvType(Class<?> t) {\n    if (!CSV_SUPPORTED.contains(t)) throw new IllegalArgumentException(\"Unsupported CSV type: \" + t);\n    return t;\n}","tryCatchPattern":"// Wrap format open in a try and surface a clear configuration error\ntry {\n    format.open(split);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"No parser available for type\")) {\n        throw new IllegalArgumentException(\n            \"A configured CSV field type has no parser. Use a supported type.\", e);\n    }\n    throw e;\n}","preventionTips":["Always set field types through the validated setters (setFieldTypesGeneric / setFieldsGeneric) so unsupported types fail at construction, not on the cluster.","Keep a unit test that calls FieldParser.getParserForType on every configured type before submitting the job.","For complex types, declare the column as String and parse it in a downstream map."],"tags":["csv","input-format","type-system","runtime"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}