floci-io/floci · error · RuntimeException
Failed to serialize v1 authorizer event
Error message
Failed to serialize v1 authorizer event
What it means
While building a REQUEST authorizer event (payload v1) — requestContext with accountId, apiId, httpMethod, path, stage, requestId — ApiGatewayExecuteController serializes it with objectMapper.writeValueAsString(event) and wraps any failure in RuntimeException('Failed to serialize v1 authorizer event'). The tree only contains strings, so a failure indicates a broken ObjectMapper configuration in the emulator, not bad caller input.
Source
Thrown at src/main/java/io/github/hectorvent/floci/services/apigateway/ApiGatewayExecuteController.java:1824
putMultiValueQueryStringParameters(event, uriInfo);
event.putObject("pathParameters");
event.putNull("stageVariables");
// Request context
ObjectNode ctx = event.putObject("requestContext");
ctx.put("accountId", regionResolver.getAccountId());
ctx.put("apiId", apiId);
ctx.put("httpMethod", httpMethod);
ctx.put("path", path);
ctx.put("resourcePath", path);
ctx.put("stage", stageName);
ctx.put("requestId", UUID.randomUUID().toString());
try {
return objectMapper.writeValueAsString(event);
} catch (Exception e) {
throw new RuntimeException("Failed to serialize v1 authorizer event", e);
}
}
/**
* Builds a REQUEST authorizer event in payload format version 2.0.
* Uses the newer HTTP API-native shape with routeArn, routeKey, rawPath, and requestContext.http.
*/
private String buildRequestAuthorizerEventV2(String httpMethod, String path, String routeKey,
String apiId, String stageName, String region,
HttpHeaders headers, UriInfo uriInfo) {
ObjectNode event = objectMapper.createObjectNode();
event.put("version", "2.0");
event.put("type", "REQUEST");
event.put("routeArn", buildMethodArn(region, apiId, stageName, httpMethod, path));
event.put("routeKey", routeKey != null ? routeKey : "$default");
event.put("rawPath", path);
event.put("rawQueryString", uriInfo.getRequestUri().getRawQuery() != null
? uriInfo.getRequestUri().getRawQuery() : "");View on GitHub (pinned to 62ff490619)
Solutions
- Reproduce with the same route without the authorizer attached; if that works, the defect is in event serialization config, not auth logic.
- Audit custom ObjectMapper producers/customizers in the build and remove them; Quarkus's default mapper handles ObjectNode fine.
- Align Jackson versions with the Quarkus BOM (`./mvnw dependency:tree -Dincludes=com.fasterxml.jackson.*`).
- For native images, register Jackson serializers for reflection and re-run the authorizer integration test.
- Upstream: log the event node and rethrow as IllegalStateException so the 500 carries a diagnosable cause.
Example fix
// before
try {
return objectMapper.writeValueAsString(event);
} catch (Exception e) {
throw new RuntimeException("Failed to serialize v1 authorizer event", e);
}
// after
try {
return objectMapper.writeValueAsString(event);
} catch (JsonProcessingException e) {
LOG.errorf(e, "V1 authorizer event serialization failed; event=%s", event);
throw new IllegalStateException("Failed to serialize v1 authorizer event", e);
} Defensive patterns
Strategy: try-catch
Try / catch
// Floci maintainer: narrow the catch and preserve the event for triage
try {
return objectMapper.writeValueAsString(event);
} catch (JsonProcessingException e) {
LOG.errorf(e, "V1 authorizer event serialization failed; event=%s", event);
throw new IllegalStateException("Failed to serialize v1 authorizer event", e);
} Prevention
- Keep the emulator's Jackson configuration stock; custom serializers belong in the app under test, not the emulator.
- Pin Jackson via the Quarkus BOM and re-check dependency:tree after any dependency addition.
- Add a unit test that serializes v1 and v2 authorizer events end-to-end to catch mapper regressions.
- Note the blast radius: only routes with REQUEST authorizers hit this path, so isolate before debugging auth logic.
When it happens
Trigger: Invoking an execute-api route protected by a REQUEST (v1) Lambda authorizer while the ObjectMapper has a failing custom serializer/module, or a custom Floci build has Jackson version conflicts. Stock builds assemble the event from plain strings (UUID, stage name, account id), so serialization cannot fail under default configuration.
Common situations: Forked emulators that customize Jackson (custom modules, date serializers, property-naming strategies), native-image packaging missing reflection metadata for the serializer, or dependency shading merging Jackson classes. The resulting 500 surfaces only on authorized routes, so it can look stage- or auth-specific.
Related errors
- Failed to serialize proxy event
- Override %s must not be blank.
- Cannot serialize to JSON: {}
- InternalServerException
- CustomResourceFailed
AI-assisted analysis of floci-io/floci@62ff490619 (2026-08-14).
Data as JSON: /api/errors/8d3b2cb63db7bcce.
Report an issue: GitHub.