{"record":{"id":"5791bd643aa3fab0","repo":"quarkusio/quarkus","slug":"could-not-serialize-the-provided-output","errorCode":null,"errorMessage":"Could not serialize the provided output.","messagePattern":"Could not serialize the provided output\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/funqy/funqy-amazon-lambda/runtime/src/main/java/io/quarkus/funqy/lambda/event/AwsEventOutputWriter.java","lineNumber":30,"sourceCode":" * Responsible for serializing the different data models of the events\n */\npublic class AwsEventOutputWriter implements LambdaOutputWriter {\n\n    final ObjectMapper mapper;\n\n    public AwsEventOutputWriter(ObjectMapper mapper) {\n        // At the moment no special configuration is needed. But we need an ObjectMapper due to different models.\n        this.mapper = mapper;\n    }\n\n    @Override\n    public void writeValue(OutputStream os, Object obj) throws IOException {\n        try {\n            mapper.writeValue(os, obj);\n        } catch (JacksonException e) {\n            // to make sure that we do not expose too many details about the issue in the lambda response\n            // we have some special treatment for jackson related issues\n            throw new IllegalArgumentException(\"Could not serialize the provided output.\", e);\n        }\n    }\n\n    @Override\n    public void writeHeaders(HttpURLConnection conn) {\n        conn.setRequestProperty(\"Content-Type\", \"application/json\");\n    }\n}\n","sourceCodeStart":12,"sourceCodeEnd":39,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/funqy/funqy-amazon-lambda/runtime/src/main/java/io/quarkus/funqy/lambda/event/AwsEventOutputWriter.java#L12-L39","documentation":"Funqy's AWS Lambda event output writer wraps any Jackson serialization failure (JacksonException) of the function's return value into a generic IllegalArgumentException so internal details are not exposed in the Lambda response. The original JacksonException is preserved as the cause.","triggerScenarios":"writeValue(OutputStream, Object) is called with a return object Jackson cannot serialize: unserializable types, self-referencing object graphs, failing getters, or invalid Jackson configuration.","commonSituations":"A funq method returns an object with non-serializable fields (streams, lazy/hydrated entities) or bidirectional references causing infinite recursion; a custom ObjectMapper module throws while writing.","solutions":["Return simple POJOs/records with Jackson-friendly getters; annotate recursive references with @JsonIgnore or @JsonManagedReference/@JsonBackReference","Inspect the JacksonException cause attached to the IllegalArgumentException to find the failing property","If raw output is needed, return a String or byte[] instead of a complex object"],"exampleFix":"// before\npublic Parent find() { Parent p = ...; p.getChild().setParent(p); return p; } // infinite recursion\n// after\npublic Parent find() { Parent p = ...; p.getChild().setParent(null); return p; }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    result = funqFunction(input);\n} catch (IllegalArgumentException e) {\n    log.error(\"Function output not serializable\", e.getCause());\n    return serverErrorResponse();\n}","preventionTips":["Return simple Jackson-friendly POJOs/records","Avoid bidirectional references or use @JsonManagedReference/@JsonBackReference","Unit-test return values with ObjectMapper.writeValueAsString"],"tags":["jackson","serialization","aws-lambda","funqy"],"backgroundTag":"json-serialization-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}