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

  1. Inspect the cause message after 'Failed to decode:' to find the mismatching property
  2. Validate/constrain the incoming JSON shape before decoding (e.g. @JsonIgnoreProperties(ignoreUnknown = true) on the target class)
  3. Verify the sender serializes with a compatible schema and encoding
  4. 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

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

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/e7f53247006692f1. Report an issue: GitHub.