{"record":{"id":"c44cb8e574b569ba","repo":"pentaho/pentaho-kettle","slug":"error-invalid-argument","errorCode":"ERROR_INVALID_ARGUMENT","errorMessage":"ERROR_INVALID_ARGUMENT (invalid argument for formula field lookup)","messagePattern":"ERROR_INVALID_ARGUMENT \\(invalid argument for formula field lookup\\)","errorType":"error_code","errorClass":"EvaluationException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/formula/RowForumulaContext.java","lineNumber":87,"sourceCode":"    return AnyType.TYPE;\n  }\n\n  /**\n   * We return the content of a Value with the given name. We cache the position of the field indexes.\n   *\n   * @see org.jfree.formula.FormulaContext#resolveReference(java.lang.Object)\n   */\n  public Object resolveReference( Object name ) throws EvaluationException {\n    if ( name instanceof String ) {\n      ValueMetaInterface valueMeta;\n      Integer idx = valueIndexMap.get( name );\n      if ( idx != null ) {\n        valueMeta = rowMeta.getValueMeta( idx.intValue() );\n      } else {\n        int index = rowMeta.indexOfValue( (String) name );\n        if ( index < 0 ) {\n          ErrorValue errorValue = new LibFormulaErrorValue( LibFormulaErrorValue.ERROR_INVALID_ARGUMENT );\n          throw new EvaluationException( errorValue );\n        }\n        valueMeta = rowMeta.getValueMeta( index );\n        idx = new Integer( index );\n        valueIndexMap.put( (String) name, idx );\n      }\n      Object valueData = rowData[idx];\n      try {\n        return getPrimitive( valueMeta, valueData );\n      } catch ( KettleValueException e ) {\n        throw new EvaluationException( LibFormulaErrorValue.ERROR_ARITHMETIC_VALUE );\n      }\n    }\n    return null;\n  }\n\n  public Configuration getConfiguration() {\n    return formulaContext.getConfiguration();\n  }","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/formula/RowForumulaContext.java#L69-L105","documentation":"EvaluationException carrying LibFormulaErrorValue.ERROR_INVALID_ARGUMENT thrown by RowForumulaContext.resolveReference() when a formula references a name that cannot be resolved to any field in the row. The row context looks up the field by index cache, then by name via rowMeta.indexOfValue(); a negative index means the referenced field does not exist.","triggerScenarios":"A formula expression references [field_name] that is absent from the row being evaluated — misspelled reference, field produced later in the stream, or field removed between metadata resolution and evaluation.","commonSituations":"Field names with special characters/typo in formula; referencing a constant by mistake without quotes; formula steps wired to a different stream than designed; renamed upstream columns.","solutions":["Correct the field reference in the formula so it exactly matches an input field name (wrap names with spaces in brackets).","Preview the input of the Formula step to confirm available field names.","Ensure upstream steps producing the referenced field run before this step.","Use string literals for constants instead of bare names (bare names are treated as field references)."],"exampleFix":"// before\n\"price * qty\"\n// after\n\"[price] * [quantity]\" // exact field names from the input row","handlingStrategy":"validation","validationCode":"// before evaluating, ensure referenced names resolve\nString[] names = rowMeta.getFieldNames();\n// verify each referenced identifier appears in names, else fix the formula","typeGuard":null,"tryCatchPattern":"try { value = formula.evaluate(); } catch (EvaluationException e) { if (e.getErrorValue() instanceof LibFormulaErrorValue) log.error(\"Unresolved formula reference, check field names: \" + e.getMessage()); throw e; }","preventionTips":["Wrap field names in square brackets in formulas","Quote literal constants so they are not treated as fields","Preview the step's input rows to confirm field availability","Avoid referencing fields produced later in the stream"],"tags":["formula","field-lookup","invalid-argument"],"backgroundTag":"invalid-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"}