{"record":{"id":"c3b3dc757778d4c6","repo":"quarkusio/quarkus","slug":"bad-input","errorCode":null,"errorMessage":"bad input","messagePattern":"bad input","errorType":"http","errorClass":"RuntimeException","httpStatus":500,"severity":"info","filePath":"integration-tests/amazon-lambda-http/src/main/java/io/quarkus/it/amazon/lambda/GreetingResource.java","lineNumber":45,"sourceCode":"    @GET\n    @Produces(MediaType.TEXT_PLAIN)\n    public String hello() {\n        return \"hello\";\n    }\n\n    @POST\n    @Produces(MediaType.TEXT_PLAIN)\n    @Consumes(MediaType.TEXT_PLAIN)\n    public String hello(String name) {\n        return \"hello \" + name;\n    }\n\n    @POST\n    @Produces(MediaType.APPLICATION_OCTET_STREAM)\n    @Consumes(MediaType.APPLICATION_OCTET_STREAM)\n    public byte[] hello(byte[] bytes) {\n        if (bytes[0] != 0 || bytes[1] != 1 || bytes[2] != 2 || bytes[3] != 3) {\n            throw new RuntimeException(\"bad input\");\n        }\n        byte[] rtn = { 4, 5, 6 };\n        return rtn;\n    }\n\n    @POST\n    @Path(\"empty\")\n    public void empty() {\n\n    }\n\n    @GET\n    @Path(\"context\")\n    @Produces(MediaType.TEXT_PLAIN)\n    public void context(@Context com.amazonaws.services.lambda.runtime.Context ctx) {\n        if (ctx == null)\n            throw new RuntimeException();\n        if (ctx.getAwsRequestId() == null)","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/amazon-lambda-http/src/main/java/io/quarkus/it/amazon/lambda/GreetingResource.java#L27-L63","documentation":"GreetingResource.hello(byte[]) is a POST endpoint consuming application/octet-stream; it validates the first four body bytes are exactly 0,1,2,3 and throws RuntimeException(\"bad input\") otherwise. It is a test endpoint verifying binary request/response bodies survive the API Gateway -> Lambda HTTP integration.","triggerScenarios":"POSTing fewer than 4 bytes (which also risks ArrayIndexOutOfBoundsException) or a byte[] whose first four bytes are not {0,1,2,3} to /hello with Content-Type application/octet-stream.","commonSituations":"Testing binary payload handling through API Gateway Lambda proxy integration; sending text/JSON to the octet-stream endpoint; base64 encoding issues where API Gateway decodes the body differently than expected.","solutions":["POST a body whose first four bytes are 0x00 0x01 0x02 0x03 (e.g. {4,5,6} comes back)","Ensure Content-Type is application/octet-stream so the correct JAX-RS method is selected","Verify API Gateway binary media types / base64 handling so the raw bytes arrive intact","Send at least 4 bytes to avoid an index-out-of-bounds before the check"],"exampleFix":"// before\ncurl -X POST --data \"abc\" http://host/hello   // bad input\n// after\nprintf '\\x00\\x01\\x02\\x03' | curl -X POST --data-binary @- -H \"Content-Type: application/octet-stream\" http://host/hello   // returns 0x04 0x05 0x06","handlingStrategy":"validation","validationCode":"byte[] bytes = ...;\nboolean ok = bytes != null && bytes.length >= 4 && bytes[0]==0 && bytes[1]==1 && bytes[2]==2 && bytes[3]==3;\nif (!ok) { /* fix payload before POSTing */ }","typeGuard":null,"tryCatchPattern":"try {\n    byte[] rtn = given().body(expected).post(\"/hello\").asByteArray();\n} catch (RuntimeException e) {\n    if (\"bad input\".equals(e.getMessage())) { /* fix payload */ }\n}","preventionTips":["Prefix binary payloads with bytes 0,1,2,3 for this test endpoint","Send at least 4 bytes to avoid ArrayIndexOutOfBoundsException","Use Content-Type: application/octet-stream so the right handler is matched","Verify API Gateway binary media types so body bytes are not base64-mangled"],"tags":["http","binary","validation","test","api-gateway"],"backgroundTag":"invalid-request-body","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"}