quarkusio/quarkus · error · DecodeException
Failed to decode:
Error message
Failed to decode:
What it means
QuarkusJacksonJsonCodec.adapt converts raw Jackson output (JsonNode, LinkedHashMap, etc.) into Vert.x JsonObject/JsonArray or plain values; any exception during decoding is wrapped in DecodeException with the message 'Failed to decode: ' plus the underlying cause message. It is invoked from fromValue and fromParser when turning buffers/values into typed objects.
Source
Thrown at extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/jackson/QuarkusJacksonJsonCodec.java:194
parser.close();
} catch (IOException ignore) {
}
}
@SuppressWarnings("rawtypes")
private static Object adapt(Object o) {
try {
if (o instanceof List) {
List list = (List) o;
return new JsonArray(list);
} else if (o instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) o;
return new JsonObject(map);
}
return o;
} catch (Exception e) {
throw new DecodeException("Failed to decode: " + e.getMessage());
}
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Inspect the cause message after 'Failed to decode:' to find the mismatching property
- Validate/constrain the incoming JSON shape before decoding (e.g. @JsonIgnoreProperties(ignoreUnknown = true) on the target class)
- Verify the sender serializes with a compatible schema and encoding
- Add a default constructor and matching field types to the target class
Example fix
// before
@JsonIgnoreProperties // absent; unknown fields cause decode failure
public class Order { private String id; }
// after
@JsonIgnoreProperties(ignoreUnknown = true)
public class Order { private String id; } Defensive patterns
Strategy: try-catch
Try / catch
try {
Order order = codec.fromBuffer(buffer, Order.class);
} catch (DecodeException e) {
log.errorf(e, "Bad event bus payload: %s", e.getMessage());
// dead-letter or reply with error
} Prevention
- Add @JsonIgnoreProperties(ignoreUnknown = true) to event bus DTOs
- Share a common schema/DTO module between producers and consumers
- Unit-test decoders against sample payloads from every producer version
When it happens
Trigger: Calling fromBuffer/fromValue/fromParser with malformed JSON bytes, or a target type Jackson cannot map the JSON to (wrong fields, incompatible types, missing no-arg constructor).
Common situations: Consuming event bus messages produced by a non-Java sender with a different JSON shape; target class changed fields (version drift); sending primitives where a JsonObject was expected; corrupted or truncated buffers.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to encode as JSON:
- Could not deserialize the provided message.
- Don't know how to get event data (dataContentType: '%s', jav
- Could not parse received event payload into type " + paramet
- Cannot create JsonArray
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/e7f53247006692f1.
Report an issue: GitHub.