floci-io/floci · error · CoercingParseLiteralException
AWSLong must be an integer
Error message
AWSLong must be an integer
What it means
Thrown by the AWSLong scalar's parseLiteral when the inline literal in the query document is not an IntValue. GraphQL integer literals cover the 32-bit range in the grammar, and this scalar only accepts that integer-literal form (it does not accept quoted numeric strings or float literals) before widening to a long.
Source
Thrown at src/main/java/io/github/hectorvent/floci/services/appsync/graphql/scalars/AppSyncScalars.java:310
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());
}
@Override
public Long parseValue(Object input) {
if (input instanceof Number n) return n.longValue();
return Long.parseLong(input.toString());
}
@Override
public Long parseLiteral(Object input) {
if (input instanceof graphql.language.IntValue iv) return iv.getValue().longValue();
throw new CoercingParseLiteralException("AWSLong must be an integer");
}
})
.build();
public static final GraphQLScalarType AWS_INTEGER = GraphQLScalarType.newScalar()
.name("AWSInteger")
.description("A 32-bit signed integer")
.coercing(new Coercing<Integer, Integer>() {
@Override
public Integer serialize(Object dataFetcherResult) {
if (dataFetcherResult == null) return null;
if (dataFetcherResult instanceof Number n) return n.intValue();
return Integer.parseInt(dataFetcherResult.toString());
}
@Override
public Integer parseValue(Object input) {
if (input instanceof Number n) return n.intValue();
return Integer.parseInt(input.toString());View on GitHub (pinned to 62ff490619)
Solutions
- Use an unquoted integer literal: f(n: 42)
- For values beyond 32-bit int range (the grammar limit), pass them as GraphQL $variables typed AWSLong instead of inline literals
- Fix codegen so numeric interpolations are not quoted
- Validate the document: AWSLong arguments must be bare integers
Example fix
# before
mutation { setCount(n: "12345678901") } # string literal -> throws
# after
mutation Set($n: AWSLong!) { setCount(n: $n) }
# variables: {"n": 12345678901} Defensive patterns
Strategy: type-guard
Validate before calling
// Only accept bare int literals inline; for big longs always use variables boolean inlineSafe = (v >= Integer.MIN_VALUE && v <= Integer.MAX_VALUE); String doc = inlineSafe ? "f(n: " + v + ")" : null; // else build a $variable version
Type guard
const isInlineIntLiteral = (v: number): boolean => Number.isInteger(v) && v >= -2147483648 && v <= 2147483647;
Try / catch
catch (CoercingParseLiteralException e) { // move the value into the variables map typed AWSLong and resend } Prevention
- Route 64-bit values through variables, never inline literals
- Never quote longs — quoting loses precision protection and fails the literal parse
- Add codegen tests for large-number rendering
When it happens
Trigger: A query document contains f(n: "9007199254740993") (string literal), f(n: 1e6) (float/exponent literal), or f(n: 42.0) where the schema declares AWSLong.
Common situations: Quoting large numbers out of JSON precision-loss paranoia — the correct fix is variables, not quotes; template engines stringifying all numbers; exponent notation from scientific sources; documents generated from JSON payloads.
Related errors
- AWSTimestamp must be an integer
- AWSBoolean must be a boolean literal
- AWSInteger must be an integer
- AWSShort must be an integer
- AWSFloat must be a number
AI-assisted analysis of floci-io/floci@62ff490619 (2026-08-14).
Data as JSON: /api/errors/396381578c559336.
Report an issue: GitHub.