{"record":{"id":"bd31f3798a6ec5f7","repo":"apache/beam","slug":"field-was-received-type-mismatch","errorCode":null,"errorMessage":" field  was received -- type mismatch","messagePattern":" field  was received -- type mismatch","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/csv/src/main/java/org/apache/beam/sdk/io/csv/CsvIOParseHelpers.java","lineNumber":158,"sourceCode":"        case BOOLEAN:\n          return Boolean.parseBoolean(cell);\n        case BYTE:\n          return Byte.parseByte(cell);\n        case DECIMAL:\n          return new BigDecimal(cell);\n        case DOUBLE:\n          return Double.parseDouble(cell);\n        case FLOAT:\n          return Float.parseFloat(cell);\n        case DATETIME:\n          return Instant.parse(cell);\n        default:\n          throw new UnsupportedOperationException(\n              \"Unsupported type: \" + fieldType + \", consider using withCustomRecordParsing\");\n      }\n\n    } catch (IllegalArgumentException e) {\n      throw new IllegalArgumentException(\n          e.getMessage() + \" field \" + field.getName() + \" was received -- type mismatch\");\n    }\n  }\n}\n","sourceCodeStart":140,"sourceCodeEnd":163,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/csv/src/main/java/org/apache/beam/sdk/io/csv/CsvIOParseHelpers.java#L140-L163","documentation":"parseCell() wraps any IllegalArgumentException thrown while converting a CSV cell (e.g. Integer.parseInt failure) into a new IllegalArgumentException whose message is '<original message> field <name> was received -- type mismatch'. The reported message shows empty brackets because the underlying message and field name were null/empty at runtime, but the cause is always a bad cell value for the declared FieldType.","triggerScenarios":"A CSV cell that cannot be parsed as the schema field's type, e.g. 'abc' in an INTEGER column, '2024-13-99' in a DATETIME column, or 'yes' in a BOOLEAN column.","commonSituations":"Dirty data files with empty or malformed cells; columns shifted so values land in the wrong fields; locale-formatted numbers ('1,5') in DOUBLE columns; Excel-exported dates in unexpected formats.","solutions":["Fix or filter malformed rows in the source CSV so each cell matches its field's type.","Mark the field nullable and supply a custom parser/empty-cell handling to tolerate blanks.","Validate data out-of-band (e.g. a dry-run parse) and log offending records before running the pipeline."],"exampleFix":"// before: csv row '1,abc' with INTEGER field 'count' -> type mismatch\n// after\nCsvIO.read(path).withCustomRecordParsing(ParsingBuilder.of(schema)\n    .setCustomParser(\"count\", cell -> cell.isEmpty() ? 0L : Long.parseLong(cell.trim()))\n    .build());","handlingStrategy":"try-catch","validationCode":"// pre-validate sample rows against field types\nlong bad = rows.filter(r -> !matchesSchema(r)).count();","typeGuard":null,"tryCatchPattern":"try { pipeline.apply(CsvIO.read(path)); } catch (IllegalArgumentException e) { LOG.error(\"CSV type mismatch: {}\", e.getMessage()); /* route file to dead-letter */ }","preventionTips":["Validate cell formats upstream (regex/date checks) before pipeline ingestion.","Use custom parsers for blank or locale-formatted numeric/date columns.","Keep a dead-letter path for malformed rows instead of failing the whole job."],"tags":["java","beam-io","csv","type-mismatch","data-quality"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}