{"record":{"id":"6e02fd1da44b7b39","repo":"quarkusio/quarkus","slug":"bad-input-6e02fd","errorCode":null,"errorMessage":"bad input","messagePattern":"bad input","errorType":"http","errorClass":"RuntimeException","httpStatus":500,"severity":"error","filePath":"integration-tests/amazon-lambda-rest-resteasy-reactive/src/main/java/io/quarkus/it/amazon/lambda/rest/resteasy/reactive/GreetingResource.java","lineNumber":36,"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":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/amazon-lambda-rest-resteasy-reactive/src/main/java/io/quarkus/it/amazon/lambda/rest/resteasy/reactive/GreetingResource.java#L18-L54","documentation":"This is an application-level runtime exception thrown by the hello endpoint in the test GreetingResource. The endpoint consumes and produces application/octet-stream and expects the first four bytes of the posted body to be 0, 1, 2, 3. Any other byte sequence causes the resource to deliberately reject the request with RuntimeException(\"bad input\"), which RESTEasy Reactive surfaces as an HTTP 500.","triggerScenarios":"POSTing a body of fewer than 4 bytes to the endpoint (which also risks ArrayIndexOutOfBoundsException) or POSTing binary data whose first four bytes are not exactly [0,1,2,3].","commonSituations":"Test clients posting plain text, JSON, or other binary payloads to the octet-stream endpoint; truncating the payload before sending; forgetting that this endpoint is an intentional failure test for AWS Lambda REST integration tests.","solutions":["Send a request body whose first four bytes are exactly 0x00,0x01,0x02,0x03 (e.g. new byte[]{0,1,2,3, ...extra}).","Ensure Content-Type and Accept headers are application/octet-stream so the right method is selected.","If testing error handling intentionally, expect the 500 response and assert on it rather than treating it as a bug."],"exampleFix":"// before\nbyte[] bad = \"hello\".getBytes();\n// after\nbyte[] good = new byte[]{0, 1, 2, 3, 42};\n// then POST with Content-Type: application/octet-stream","handlingStrategy":"validation","validationCode":"byte[] body = new byte[]{0, 1, 2, 3};\nif (body.length < 4 || body[0] != 0 || body[1] != 1 || body[2] != 2 || body[3] != 3) {\n    throw new IllegalArgumentException(\"body must start with bytes 0,1,2,3\");\n}","typeGuard":"boolean isValidBinary(byte[] b) { return b != null && b.length >= 4 && b[0] == 0 && b[1] == 1 && b[2] == 2 && b[3] == 3; }","tryCatchPattern":"try {\n    byte[] resp = client.post(body);\n} catch (javax.ws.rs.InternalServerErrorException e) {\n    log.error(\"Server rejected payload as bad input\", e);\n}","preventionTips":["Always build the payload with the magic prefix bytes 0,1,2,3.","Set Content-Type: application/octet-stream on the request.","Never send payloads shorter than 4 bytes."],"tags":["resteasy-reactive","binary-payload","input-validation"],"backgroundTag":"invalid-request-payload","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}