quarkusio/quarkus · info · RuntimeException

bad input

Error message

bad input

What it means

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.

Source

Thrown at integration-tests/amazon-lambda-http/src/main/java/io/quarkus/it/amazon/lambda/GreetingResource.java:45

    @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. POST a body whose first four bytes are 0x00 0x01 0x02 0x03 (e.g. {4,5,6} comes back)
  2. Ensure Content-Type is application/octet-stream so the correct JAX-RS method is selected
  3. Verify API Gateway binary media types / base64 handling so the raw bytes arrive intact
  4. Send at least 4 bytes to avoid an index-out-of-bounds before the check

Example fix

// before
curl -X POST --data "abc" http://host/hello   // bad input
// after
printf '\x00\x01\x02\x03' | curl -X POST --data-binary @- -H "Content-Type: application/octet-stream" http://host/hello   // returns 0x04 0x05 0x06
Defensive patterns

Strategy: validation

Validate before calling

byte[] bytes = ...;
boolean ok = bytes != null && bytes.length >= 4 && bytes[0]==0 && bytes[1]==1 && bytes[2]==2 && bytes[3]==3;
if (!ok) { /* fix payload before POSTing */ }

Try / catch

try {
    byte[] rtn = given().body(expected).post("/hello").asByteArray();
} catch (RuntimeException e) {
    if ("bad input".equals(e.getMessage())) { /* fix payload */ }
}

Prevention

When it happens

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

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

Related errors


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