quarkusio/quarkus · error · RuntimeException

bad input

Error message

bad input

What it means

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.

Source

Thrown at integration-tests/amazon-lambda-rest-resteasy-reactive/src/main/java/io/quarkus/it/amazon/lambda/rest/resteasy/reactive/GreetingResource.java:36

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        return "hello";
    }

    @POST
    @Produces(MediaType.TEXT_PLAIN)
    @Consumes(MediaType.TEXT_PLAIN)
    public String hello(String name) {
        return "hello " + name;
    }

    @POST
    @Produces(MediaType.APPLICATION_OCTET_STREAM)
    @Consumes(MediaType.APPLICATION_OCTET_STREAM)
    public byte[] hello(byte[] bytes) {
        if (bytes[0] != 0 || bytes[1] != 1 || bytes[2] != 2 || bytes[3] != 3) {
            throw new RuntimeException("bad input");
        }
        byte[] rtn = { 4, 5, 6 };
        return rtn;
    }

    @POST
    @Path("empty")
    public void empty() {

    }

    @GET
    @Path("context")
    @Produces(MediaType.TEXT_PLAIN)
    public void context(@Context com.amazonaws.services.lambda.runtime.Context ctx) {
        if (ctx == null)
            throw new RuntimeException();
        if (ctx.getAwsRequestId() == null)

View on GitHub (pinned to e1c734241f)

Solutions

  1. Send a request body whose first four bytes are exactly 0x00,0x01,0x02,0x03 (e.g. new byte[]{0,1,2,3, ...extra}).
  2. Ensure Content-Type and Accept headers are application/octet-stream so the right method is selected.
  3. If testing error handling intentionally, expect the 500 response and assert on it rather than treating it as a bug.

Example fix

// before
byte[] bad = "hello".getBytes();
// after
byte[] good = new byte[]{0, 1, 2, 3, 42};
// then POST with Content-Type: application/octet-stream
Defensive patterns

Strategy: validation

Validate before calling

byte[] body = new byte[]{0, 1, 2, 3};
if (body.length < 4 || body[0] != 0 || body[1] != 1 || body[2] != 2 || body[3] != 3) {
    throw new IllegalArgumentException("body must start with bytes 0,1,2,3");
}

Type guard

boolean isValidBinary(byte[] b) { return b != null && b.length >= 4 && b[0] == 0 && b[1] == 1 && b[2] == 2 && b[3] == 3; }

Try / catch

try {
    byte[] resp = client.post(body);
} catch (javax.ws.rs.InternalServerErrorException e) {
    log.error("Server rejected payload as bad input", e);
}

Prevention

When it happens

Trigger: 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].

Common situations: 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.

Related errors


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