{"record":{"id":"0b6f8b67bcbddde5","repo":"pentaho/pentaho-kettle","slug":"api-error-valuemetainterface-can-t-be-null","errorCode":null,"errorMessage":"API error. ValueMetaInterface can't be null!","messagePattern":"API error\\. ValueMetaInterface can't be null!","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/ValueDataUtil.java","lineNumber":2259,"sourceCode":"    } catch ( Exception e ) {\n      throw new KettleValueException( e );\n    } finally {\n      IOUtils.closeQuietly( file );\n    }\n    return encoding;\n  }\n\n  /**\n   *  Default utility method to get exact zero value according to ValueMetaInterface. Using\n   *  this utility method saves from ClassCastExceptions later.\n   *\n   * @param type\n   * @return\n   * @throws KettleValueException\n   */\n  public static Object getZeroForValueMetaType( ValueMetaInterface type ) throws KettleValueException {\n    if ( type == null ) {\n      throw new KettleValueException( \"API error. ValueMetaInterface can't be null!\" );\n    }\n\n    switch ( type.getType() ) {\n      case ( ValueMetaInterface.TYPE_INTEGER ) : {\n        return new Long( 0 );\n      }\n      case ( ValueMetaInterface.TYPE_NUMBER ) : {\n        return new Double( 0 );\n      }\n      case ( ValueMetaInterface.TYPE_BIGNUMBER ) : {\n        return new BigDecimal( 0 );\n      }\n      case ( ValueMetaInterface.TYPE_STRING ) : {\n        return \"\";\n      }\n      default : {\n        throw new KettleValueException( \"get zero function undefined for data type: \" + type.getType() );\n      }","sourceCodeStart":2241,"sourceCodeEnd":2277,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/ValueDataUtil.java#L2241-L2277","documentation":"ValueDataUtil.getZeroForValueMetaType returns the zero value (0, 0.0, BigDecimal.ZERO, \"\", etc.) for a given ValueMetaInterface type, and explicitly rejects a null argument with this KettleValueException as an API contract check.","triggerScenarios":"Calling ValueDataUtil.getZeroForValueMetaType(null) — typically when a ValueMeta lookup returned null, e.g. a field was absent from the row meta or a metadata lookup failed and the null was passed straight through.","commonSituations":"Field removed/renamed upstream so getFieldFromRow/getValueMeta returns null; programmatically built ValueMeta objects where type resolution was skipped; plugin code assuming a field always exists in the row.","solutions":["Pass a non-null ValueMetaInterface — resolve the field from RowMetaInterface first and fail early if it is missing","Guard the call: if ( type != null ) before invoking getZeroForValueMetaType","Fix the lookup that produced null (check field names/case and step connectivity)","If you only need a zero for a known type constant, construct it directly instead of via ValueMeta"],"exampleFix":"// before\nObject zero = ValueDataUtil.getZeroForValueMetaType( rowMeta.getValueMeta( idx ) ); // idx out of range => null\n// after\nValueMetaInterface type = idx >= 0 && idx < rowMeta.size() ? rowMeta.getValueMeta( idx ) : null;\nObject zero = ( type != null ) ? ValueDataUtil.getZeroForValueMetaType( type ) : null;","handlingStrategy":"type-guard","validationCode":"if ( type == null ) { throw new IllegalArgumentException( \"ValueMetaInterface must not be null\" ); }","typeGuard":"ValueMetaInterface requireValueMeta( ValueMetaInterface m ) { if ( m == null ) throw new IllegalArgumentException( \"null ValueMeta\" ); return m; }","tryCatchPattern":"try {\n  return ValueDataUtil.getZeroForValueMetaType( type );\n} catch ( KettleValueException e ) {\n  if ( e.getMessage() != null && e.getMessage().contains( \"can't be null\" ) ) {\n    log.error( \"ValueMeta lookup produced null — check field name/step mapping\" );\n    return null;\n  }\n  throw e;\n}","preventionTips":["Never pass through the result of rowMeta.getValueMeta(idx) without an index bounds check","Fail fast on missing fields during transformation initialization","Verify field names and case when resolving metadata lookups"],"tags":["null-value","api-contract","kettle"],"backgroundTag":"null-argument","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"}