Contact Us 1-800-596-4880

Troubleshooting in DataWeave

DataWeave 1.1 is compatible with Mule Runtime Engine 3.8. MuleSoft recommends against deployments to Mule 3.8. Standard Support for this version ended on November 16, 2018, and Mule 3.8 will reach its End of Life on November 16, 2021, when Extended Support ends.

This document lists common error messages, what these mean and how to resolve them.

Cannot coerce :binary to :object

It means that DataWeave is trying to transform a binary value to an object, which isn’t allowed.

Cause: One possible case is that DataWeave is reading the content as binary as it was an 'InputStream' or 'Byte array' and its mime type is not set. In this scenario DataWeave defaults to Java reader. If you look at the Info log it would display something like this:

MimeType was not resolved '*/*' delegating to Java.

Solution : Validate that the mimeType is set. For example verify that if your data source has a mime-type field, its value is set, or if the value is set through a set-payload or set-variable component, then the mime-type property was defined in it.

Cannot coerce :string to :object

It means that DataWeave is trying to transform a string value to type object.

Cause: Same as Cannot coerce :binary to :object, this may be a mime-type problem.

Cause: If the value is an XML, this may be caused by an empty tag. By default the XML reader reads

Take the following example:

Input
<user></user>
Transform
payload.user.name

The above script fails with the error Cannot coerce :string to :object

Reason: As you can see the input XML is an empty XML tag, so the expression payload.user returns an empty string. Then DataWeave tries to apply the 'name' selector over a string, which raises an exception.

Solution: The XML reader has a configuration property named 'nullValueOn'. This property can be set to "blank" or "empty", which can fix this issue. To set this property see To Define Input and Output Structure of a Transformation.