{"record":{"id":"d2c18881ed0e3ad4","repo":"pentaho/pentaho-kettle","slug":"pgbulkloader-doesn-t-know-how-to-handle-date-neither","errorCode":null,"errorMessage":"PGBulkLoader doesn't know how to handle date (neither passthrough, nor date or datetime for field ","messagePattern":"PGBulkLoader doesn't know how to handle date \\(neither passthrough, nor date or datetime for field ","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/postgresql-db-bulk-loader/impl/src/main/java/org/pentaho/di/trans/steps/pgbulkloader/PGBulkLoader.java","lineNumber":354,"sourceCode":"                //\n                case PGBulkLoaderMeta.NR_DATE_MASK_DATE:\n                  String dateString = data.dateMeta.getString( valueMeta.getDate( valueData ) );\n                  if ( dateString != null ) {\n                    pgCopyOut.write( dateString.getBytes( clientEncoding ) );\n                  }\n                  break;\n\n                // Convert to a \"YYYY-MM-DD HH:MM:SS.mmm\" format\n                //\n                case PGBulkLoaderMeta.NR_DATE_MASK_DATETIME:\n                  String dateTimeString = data.dateTimeMeta.getString( valueMeta.getDate( valueData ) );\n                  if ( dateTimeString != null ) {\n                    pgCopyOut.write( dateTimeString.getBytes( clientEncoding ) );\n                  }\n                  break;\n\n                default:\n                  throw new KettleException( \"PGBulkLoader doesn't know how to handle date (neither passthrough, nor date or datetime for field \" + valueMeta.getName() );\n              }\n              break;\n            case ValueMetaInterface.TYPE_TIMESTAMP:\n              // Format the date in the right format.\n              //\n              switch ( data.dateFormatChoices[i] ) {\n              // Pass the data along in the format chosen by the user OR in binary format...\n              //\n                case PGBulkLoaderMeta.NR_DATE_MASK_PASS_THROUGH:\n                  if ( valueMeta.isStorageBinaryString() ) {\n                    pgCopyOut.write( (byte[]) valueData );\n                  } else {\n                    String dateString = valueMeta.getString( valueData );\n                    if ( dateString != null ) {\n                      pgCopyOut.write( dateString.getBytes( clientEncoding ) );\n                    }\n                  }\n                  break;","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/postgresql-db-bulk-loader/impl/src/main/java/org/pentaho/di/trans/steps/pgbulkloader/PGBulkLoader.java#L336-L372","documentation":"When writing a row field of type Date to the COPY stream, writeRowToPostgres switches on data.dateFormatChoices[i]; the default branch fires when the date format choice is none of passthrough/date/datetime. This is an internal configuration mismatch for that field's date handling.","triggerScenarios":"A field of ValueMetaInterface.TYPE_DATE reaches writeRowToPostgres while its entry in data.dateFormatChoices was never initialized to one of the supported choices (passthrough, date, datetime), e.g. meta loaded from an unrecognized/empty date_mask value.","commonSituations":"Older or hand-edited transformation XML where the date mask attribute is missing or has an unexpected value; repository record with a corrupted date_mask string; version upgrade changing the recognized mask constants so a stored value no longer maps to a choice.","solutions":["Open the step's Fields tab and explicitly set a Date format (Date mask) for every date field, then re-save","Inspect the saved transformation/repo metadata for the field's date_mask value and correct it to a recognized value","Recreate the field mapping with 'Get Fields' so defaults are applied cleanly","Patch PGBulkLoaderMeta.readData/readRep handling so unknown masks fall back to a valid default instead of producing an unmapped choice"],"exampleFix":"// before (unmapped mask)\ndateMask[i] = \"weird_mask\"; // -> dateFormatChoices[i] hits default\n// after\nmeta.setDateMask( i, PGBulkLoaderMeta.getDateMaskDefault() ); // recognized constant","handlingStrategy":"validation","validationCode":"// verify each date field has a recognized mask in the saved meta\nfor ( int i = 0; i < meta.getFieldStream().length; i++ ) {\n  String mask = meta.getFieldDateMask()[i];\n  if ( mask == null || !List.of( \"Pass through\", \"Date mask\", \"DateTime mask\" ).contains( mask ) ) {\n    throw new IllegalStateException( \"Unrecognized date mask for field \" + meta.getFieldStream()[i] );\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  step.processRow();\n} catch ( KettleException e ) {\n  if ( e.getMessage().contains( \"doesn't know how to handle date\" ) ) {\n    // reconfigure the date mask for the named field\n  }\n}","preventionTips":["Explicitly set a Date mask for every date field in the Fields tab","After version upgrades, re-save transformations to normalize stored masks","Avoid hand-editing date_mask values in ktr XML"],"tags":["kettle","postgresql","date-format","configuration"],"backgroundTag":"invalid-enum-value","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}