{"record":{"id":"d38797e87cd48e21","repo":"pentaho/pentaho-kettle","slug":"unable-to-parse-expression-expression-with-ognl","errorCode":null,"errorMessage":"Unable to parse expression [<expression>] with Ognl","messagePattern":"Unable to parse expression \\[<expression>\\] with Ognl","errorType":"exception","errorClass":"KettleConfigException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/config/PropertySetter.java","lineNumber":94,"sourceCode":"      return BaseMessages.getString( packageName, key );\n    } else {\n      throw new KettleConfigException(\n        \"the i18, directive need 3 parameters: i18n, the package name and the key, but \"\n          + expression.length + \" parameters were found in [\" + value + \"]\" );\n    }\n  }\n\n  private Object setOgnlProperty( String[] expression, String value ) throws KettleConfigException {\n    if ( expression.length >= 2 ) {\n      OgnlExpression expr = ognlExpressions.get( value );\n      if ( expr == null ) {\n        synchronized ( ognlExpressions ) {\n          try {\n            expr = new OgnlExpression( expression[1] );\n            ognlExpressions.put( value, expr );\n\n          } catch ( OgnlException e ) {\n            throw new KettleConfigException( \"Unable to parse expression [\" + expression[1] + \"] with Ognl\", e );\n          }\n        }\n      }\n\n      // evaluate\n      try {\n        return expr.getValue( octx, this );\n      } catch ( OgnlException e ) {\n        throw new KettleConfigException(\n          \"Unable to get value for expression [\" + expression[1] + \"] with Ognl\", e );\n      }\n    } else {\n      throw new KettleConfigException(\n        \"the ognl, directive need at least 2 parameters: ongl and the expression but \"\n          + expression.length + \" parameters were found in [\" + value + \"]\" );\n    }\n  }\n}","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/config/PropertySetter.java#L76-L112","documentation":"setOgnlProperty compiles the OGNL expression (second token of an 'ognl:expression' value) into an OgnlExpression, caching compiled expressions. This error is thrown when OGNL fails to parse the expression syntax (OgnlException), wrapped in a KettleConfigException with the offending expression text.","triggerScenarios":"Calling setProperty with a value like 'ognl:<bad syntax>' where expression[1] is not valid OGNL — e.g. unbalanced parentheses, invalid identifiers, malformed method calls.","commonSituations":"Hand-written OGNL in config files with typos; expressions referencing removed/renamed properties that fail at parse time; colons inside the expression truncating it since the value is split on ':' before parsing.","solutions":["Fix the OGNL expression syntax in the config value; test it in an OGNL evaluator first.","Remove colons from the expression or restructure it, since the value is split on ':' — only token[1] onward matters but splitting corrupts complex expressions.","Validate expression[1] with ognl.Ognl.parseExpression() in a unit test before shipping the config.","Catch KettleConfigException during config load and log expression[1] to pinpoint the bad config entry."],"exampleFix":"// before\npropertySetter.setProperty(obj, \"name\", \"ognl:getNaem()\");\n\n// after\npropertySetter.setProperty(obj, \"name\", \"ognl:getName()\");","handlingStrategy":"try-catch","validationCode":"try {\n  org.apache.commons.ognl.Ognl.parseExpression(exprString);\n} catch (Exception e) {\n  throw new IllegalArgumentException(\"Invalid OGNL expression in config: \" + exprString, e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  propertySetter.setProperty(obj, property, value);\n} catch (KettleConfigException e) {\n  LOG.error(\"OGNL parse failed for property \" + property + \", value=\" + value, e);\n}","preventionTips":["Test OGNL expressions in a scratch evaluator before committing them to config.","Avoid colons inside OGNL expressions since values are split on ':'.","Add CI validation that compiles all ognl: config values."],"tags":["config","ognl","expression-parsing"],"backgroundTag":"invalid-regex-pattern","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"}