floci-io/floci · error · CoercingParseValueException
AWSBoolean cannot parse non-boolean value: {}
Error message
AWSBoolean cannot parse non-boolean value: {} What it means
Thrown by the AWSBoolean scalar's parseValue when an incoming variable value for an AWSBoolean field is not a java.lang Boolean. Variables arrive as parsed JSON, so a JSON string "true" or number 1 does not satisfy the instanceof check and the strict scalar rejects it instead of coercing.
Source
Thrown at src/main/java/io/github/hectorvent/floci/services/appsync/graphql/scalars/AppSyncScalars.java:282
return parseValue(sv.getValue());
}
})
.build();
public static final GraphQLScalarType AWS_BOOLEAN = GraphQLScalarType.newScalar()
.name("AWSBoolean")
.description("A boolean value")
.coercing(new Coercing<Boolean, Boolean>() {
@Override
public Boolean serialize(Object dataFetcherResult) {
if (dataFetcherResult == null) return null;
if (dataFetcherResult instanceof Boolean b) return b;
throw new CoercingSerializeException("AWSBoolean cannot serialize non-boolean value: " + dataFetcherResult.getClass().getSimpleName());
}
@Override
public Boolean parseValue(Object input) {
if (input instanceof Boolean b) return b;
throw new CoercingParseValueException("AWSBoolean cannot parse non-boolean value: " + input);
}
@Override
public Boolean parseLiteral(Object input) {
if (input instanceof graphql.language.BooleanValue bv) return bv.isValue();
throw new CoercingParseLiteralException("AWSBoolean must be a boolean literal");
}
})
.build();
public static final GraphQLScalarType AWS_LONG = GraphQLScalarType.newScalar()
.name("AWSLong")
.description("A 64-bit signed integer")
.coercing(new Coercing<Long, Long>() {
@Override
public Long serialize(Object dataFetcherResult) {
if (dataFetcherResult == null) return null;
if (dataFetcherResult instanceof Number n) return n.longValue();
return Long.parseLong(dataFetcherResult.toString());View on GitHub (pinned to 62ff490619)
Solutions
- Send a real JSON boolean: variables {"flag": true} — unquoted
- When building from strings, convert first: Boolean.parseBoolean(s)
- Fix hand-written JSON fixtures: search for \"true\" / \"false\" near AWSBoolean fields
- Add a client-side type check on the variables map before dispatch
Example fix
// before
variables.put("flag", request.getParameter("flag")); // "true" string -> throws
// after
variables.put("flag", Boolean.parseBoolean(request.getParameter("flag"))); // true Defensive patterns
Strategy: type-guard
Validate before calling
Object v = variables.get("flag");
if (!(v instanceof Boolean)) throw new IllegalArgumentException("flag must be a JSON boolean (true/false), got: " + v); Type guard
const isAwsBooleanValue = (v: unknown): v is boolean => typeof v === 'boolean';
Try / catch
catch (CoercingParseValueException e) { // convert the source string with Boolean.parseBoolean and resend } Prevention
- Never quote booleans in variable JSON
- Convert form/query params with Boolean.parseBoolean at the boundary
- Type-check the variables map in one shared pre-flight step
When it happens
Trigger: A GraphQL request passes variables {"flag": "true"} or {"flag": 1} or {"flag": "yes"} where the schema declares $flag: AWSBoolean — the JSON value is a string/number, not a boolean.
Common situations: Client code building variables from form inputs or query strings where everything is a string; Templates/ENV-driven config interpolated as strings ("true" instead of true); Language serializers that encode booleans as 0/1 or "Y"/"N" by convention; Test fixtures written by hand with quoted booleans.
Related errors
- AWSBoolean must be a boolean literal
- BadRequestException
- Invalid JSON: {}
- Invalid AWSDateTime: {}
- Invalid AWSDate: {}
AI-assisted analysis of floci-io/floci@62ff490619 (2026-08-14).
Data as JSON: /api/errors/e4b48d69202b4412.
Report an issue: GitHub.