floci-io/floci · error · CoercingParseLiteralException

AWSInteger must be an integer

Error message

AWSInteger must be an integer

What it means

Thrown by the AWSInteger scalar's parseLiteral when the inline literal in the query document is not an IntValue — i.e. it is a string, float, boolean, or null literal. The scalar requires a bare 32-bit integer literal in the document text.

Source

Thrown at src/main/java/io/github/hectorvent/floci/services/appsync/graphql/scalars/AppSyncScalars.java:333

    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());
            }
            @Override
            public Integer parseLiteral(Object input) {
                if (input instanceof graphql.language.IntValue iv) return iv.getValue().intValue();
                throw new CoercingParseLiteralException("AWSInteger must be an integer");
            }
        })
        .build();

    public static final GraphQLScalarType AWS_SHORT = GraphQLScalarType.newScalar()
        .name("AWSShort")
        .description("A 16-bit signed integer (-32768 to 32767)")
        .coercing(new Coercing<Integer, Integer>() {
            @Override
            public Integer serialize(Object dataFetcherResult) {
                if (dataFetcherResult instanceof Number n) return n.intValue();
                return Integer.parseInt(dataFetcherResult.toString());
            }
            @Override
            public Integer parseValue(Object input) {
                int val;
                if (input instanceof Number n) val = n.intValue();
                else val = Integer.parseInt(input.toString());

View on GitHub (pinned to 62ff490619)

Solutions

  1. Write the bare integer literal: f(n: 7)
  2. Round or convert floats to ints before interpolation: Math.round(x)
  3. Pass values as $variables typed AWSInteger rather than inline literals
  4. Null belongs in the variables map (variable set to null), not as an inline literal for this scalar

Example fix

# before
query { item(score: "7") } # quoted -> throws

# after
query { item(score: 7) }
Defensive patterns

Strategy: type-guard

Validate before calling

static String intLiteral(Object v) {
    if (v instanceof Integer i) return i.toString();
    throw new IllegalArgumentException("AWSInteger argument must be a bare int literal");
}

Type guard

const isInlineIntLiteral = (v: unknown): boolean => Number.isInteger(v);

Try / catch

catch (CoercingParseLiteralException e) { // unquote/round the literal or move it to a $variable }

Prevention

When it happens

Trigger: A query document contains f(n: "7"), f(n: 7.5), f(n: true), or f(n: null) where the argument/field is typed AWSInteger.

Common situations: Query builders quoting every interpolated value; JSON-style fixtures pasted into GraphQL documents (quoted numbers); float-typed constants (discount rates, scores) passed to integer fields; null literals used to mean 'skip' in inline positions.

Related errors


AI-assisted analysis of floci-io/floci@62ff490619 (2026-08-14). Data as JSON: /api/errors/1a9f0dc9a0827941. Report an issue: GitHub.