{"record":{"id":"2204f4912028d3f4","repo":"pentaho/pentaho-kettle","slug":"error-creating-value","errorCode":null,"errorMessage":"Error creating value","messagePattern":"Error creating value","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java","lineNumber":633,"sourceCode":"        // If we don't have a target data type, throw an error.\n        // Otherwise the result is non-deterministic.\n        //\n        if ( targetMeta.getType() == ValueMetaInterface.TYPE_NONE ) {\n          throw new KettleValueException( BaseMessages.getString( PKG, \"Calculator.Log.NoType\" )\n            + ( i + 1 ) + \" : \" + fn.getFieldName() + \" = \" + fn.getCalcTypeDesc() + \" / \"\n            + fn.getCalcTypeLongDesc() );\n        }\n\n        // Convert the data to the correct target data type.\n        //\n        if ( calcData[index] != null ) {\n          if ( targetMeta.getType() != resultType ) {\n            ValueMetaInterface resultMeta;\n            try {\n              // clone() is not necessary as one data instance belongs to one step instance and no race condition occurs\n              resultMeta = data.getValueMetaFor( resultType, \"result\" );\n            } catch ( Exception exception ) {\n              throw new KettleValueException( \"Error creating value\" );\n            }\n            resultMeta.setConversionMask( fn.getConversionMask() );\n            resultMeta.setGroupingSymbol( fn.getGroupingSymbol() );\n            resultMeta.setDecimalSymbol( fn.getDecimalSymbol() );\n            resultMeta.setCurrencySymbol( fn.getCurrencySymbol() );\n            try {\n              calcData[index] = targetMeta.convertData( resultMeta, calcData[index] );\n            } catch ( Exception ex ) {\n              throw new KettleValueException( \"resultType: \"\n                + resultType + \"; targetMeta: \" + targetMeta.getType(), ex );\n            }\n          }\n        }\n      }\n    }\n\n    // OK, now we should refrain from adding the temporary fields to the result.\n    // So we remove them.","sourceCodeStart":615,"sourceCodeEnd":651,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java#L615-L651","documentation":"Calculator's calcFields wraps any exception thrown while obtaining the internal ValueMeta cache entry for the computed result type (data.getValueMetaFor) as a KettleValueException with the generic message 'Error creating value'. This is an internal metadata-construction failure, not a data error; the actual cause is hidden because the exception is not chained.","triggerScenarios":"calcFields computes a field whose resultType has no (or an invalid) combination of value-meta type and conversion settings such that the ValueMeta factory throws, while processing a row through the Calculator step.","commonSituations":"Calculator functions producing exotic result types (e.g. arithmetic producing BigNumber/String combos), corrupted step metadata after upgrade, or a Kettle version where ValueMeta construction for a type is unsupported.","solutions":["Enable detailed/developer logging or debug the step to see the suppressed cause inside the wrapped exception","Verify each Calculator field's conversion mask/decimal/currency/grouping symbols are valid for the chosen target type","Recreate the Calculator step metadata (copy fields into a fresh step) to clear stale/invalid settings","Upgrade/patch Kettle engine if the result type is known-valid but getValueMetaFor still fails"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before running the transformation, verify Calculator result types are buildable\nfor (CalculatorMetaFunction fn : meta.getCalculation()) {\n  if (fn.getCalcType() < 0 || fn.getFieldName() == null)\n    throw new IllegalStateException(\"Invalid calculator function definition: \" + fn);\n}","typeGuard":"boolean isValidFunction(CalculatorMetaFunction fn) {\n  return fn != null && fn.getFieldName() != null && fn.getCalcType() >= 0;\n}","tryCatchPattern":"try { row = calcFields(...); } catch (KettleValueException e) {\n  logError(\"Calculator value creation failed on field \" + fn.getFieldName(), e);\n  throw e;\n}","preventionTips":["Keep conversion masks consistent with the declared target type","Rebuild Calculator step metadata after Pentaho upgrades","Validate transformations with Spoon's 'Verify' before running"],"tags":["pdi","value-metadata","calculator"],"backgroundTag":"internal-invariant-violation","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"}