Loading

Invalid payload may lead to ExpressionRuntimeException error

Data pubblicazione: Jul 22, 2025
Risoluzione

SYMPTOM

While using substring function,  Mule application is throwing ExpressionRuntimeException.  

HTTP/1.1 500 Execution of the expression
"message.inboundProperties['http.request.path'].substring(message.inboundProperties['http.request.path'].indexOf('/1'))" failed. (org.mule.api.expression.ExpressionRuntimeException).

CAUSE

ExpressionRuntimeException can caused either because of the expression itself is not correct of the data that expression is processing is not as expected.  Although the exact root cause differs on case by case basis, below is one example which could lead to such error. 

Test Case:    Simple application with http listener and 3 different loggers using Mule expressions with substring function which relies on the request path extracted from message.inboundProperties.   Application tested with end point: localhost:8081/test/mule/support.

1. <logger message="#[message.inboundProperties['http.request.path']]" level="INFO" doc:name="Logger"/>
2. <logger message="#[message.inboundProperties['http.request.path'].substring(message.inboundProperties['http.request.path'].indexOf('/mule'))]" level="INFO" doc:name="Logger"/>
3. <logger message="#[message.inboundProperties['http.request.path'].substring(message.inboundProperties['http.request.path'].indexOf('/1'))]" level="INFO" doc:name="Logger"/>

1st one: Success
INFO 2022-05-19 16:37:40,685 [[testhttppath].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: /test/mule/support

2nd one : Success
INFO 2022-05-19 16:37:40,692 [[testhttppath].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: /mule/support

3rd one : Failed 
Message : Execution of the expression "message.inboundProperties['http.request.path'].substring(message.inboundProperties['http.request.path'].indexOf('/1'))" failed. (org.mule.api.expression.ExpressionRuntimeException).
 

SOLUTION

This can be resolved by ensuring the data that Mule expression is trying to process is appropriate.  In above case the path does not content the string ('/1') which is used for indexOf function and hence the function will return NullPayload and that will eventually throw ExpressionRuntimeException. 

Numero articolo Knowledge

001119282

 
Caricamento
Salesforce Help | Article