quarkusio/quarkus · error · IllegalArgumentException

Could not deserialize the provided message.

Error message

Could not deserialize the provided message.

What it means

Funqy's AWS Lambda event input reader wraps any Jackson deserialization failure (JacksonException) of the incoming event payload into a generic IllegalArgumentException. This hides Jackson internals so that too many details are not exposed in the Lambda response. The original JacksonException is preserved as the cause.

Source

Thrown at extensions/funqy/funqy-amazon-lambda/runtime/src/main/java/io/quarkus/funqy/lambda/event/AwsEventInputReader.java:64

        // configure the mapper for advanced event handling
        final SimpleModule simpleModule = new SimpleModule();
        simpleModule.addDeserializer(Date.class, new DateDeserializer());
        builder.addModule(simpleModule);
        builder.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

        this.mapper = builder.build();
        this.amazonBuildTimeConfig = amazonBuildTimeConfig;
        this.reader = reader;
    }

    @Override
    public Object readValue(InputStream is) throws IOException {
        try {
            return safelyReadValue(is);
        } catch (JacksonException e) {
            // to make sure that we do not expose too many details about the issue in the lambda response
            // we have some special treatment for jackson related issues
            throw new IllegalArgumentException("Could not deserialize the provided message.", e);
        }
    }

    private Object safelyReadValue(final InputStream is) throws IOException {
        final JsonNode rootNode = mapper.readTree(is);

        if (amazonBuildTimeConfig.advancedEventHandling().enabled()) {
            if (rootNode.isObject() || rootNode.isArray()) {
                if (rootNode.isObject()) {
                    // object
                    ObjectNode object = (ObjectNode) rootNode;

                    if (object.has("Records") && object.get("Records").isArray()) {
                        // We need to look into the first record entry, to distinguish the different types.
                        for (JsonNode record : object.get("Records")) {
                            return deserializeEvent(record, object);
                        }
                    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Log/inspect the raw event payload and validate it is well-formed JSON before invoking the Lambda
  2. Check the funq method's input parameter type matches the actual event body structure
  3. Inspect the JacksonException attached as the cause of the IllegalArgumentException for the real deserialization error
  4. If the input is an AWS event type (SQS/DynamoDB/etc.), use the dedicated event handler / take the specific event type as the funq parameter instead of plain JSON

Example fix

// before: sending invalid JSON body to function
lambda.invoke("{not valid json");
// after: send valid JSON matching the funq input type
lambda.invoke("{\"name\":\"world\"}");
Defensive patterns

Strategy: try-catch

Validate before calling

// validate payload before invoking
try (InputStream is = payloadStream) {
    new ObjectMapper().readTree(is); // throws if not valid JSON
}

Try / catch

try {
    result = invokeLambda(payload);
} catch (IllegalArgumentException e) {
    // JacksonException cause holds the details
    log.error("Invalid event payload", e.getCause());
    return badRequestResponse();
}

Prevention

When it happens

Trigger: readValue(InputStream) is called with a stream that is not valid JSON, has the wrong shape for the target function parameter type, or is empty/truncated.

Common situations: Invoking a Funqy Lambda with a hand-crafted test event that is not valid JSON; sending a payload that does not match the function's input POJO (missing/renamed fields, wrong types); API Gateway or SQS events hitting a function expecting raw JSON.

Related errors


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