floci-io/floci · error · CoercingParseLiteralException

AWSFloat must be a number

Error message

AWSFloat must be a number

What it means

Thrown by the AWSFloat scalar's parseLiteral when the inline literal is neither a FloatValue nor an IntValue (e.g. a string or boolean literal). The scalar accepts both decimal and whole-number literals on the literal path, converting integers to double, but rejects everything else.

Source

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

        .name("AWSFloat")
        .description("An IEEE 754 double-precision float")
        .coercing(new Coercing<Double, Double>() {
            @Override
            public Double serialize(Object dataFetcherResult) {
                if (dataFetcherResult == null) return null;
                if (dataFetcherResult instanceof Number n) return n.doubleValue();
                return Double.parseDouble(dataFetcherResult.toString());
            }
            @Override
            public Double parseValue(Object input) {
                if (input instanceof Number n) return n.doubleValue();
                return Double.parseDouble(input.toString());
            }
            @Override
            public Double parseLiteral(Object input) {
                if (input instanceof graphql.language.FloatValue fv) return fv.getValue().doubleValue();
                if (input instanceof graphql.language.IntValue iv) return iv.getValue().doubleValue();
                throw new CoercingParseLiteralException("AWSFloat must be a number");
            }
        })
        .build();

    public static final GraphQLScalarType AWS_BIG_DECIMAL = GraphQLScalarType.newScalar()
        .name("AWSBigDecimal")
        .description("An arbitrary-precision decimal number")
        .coercing(new Coercing<String, String>() {
            @Override
            public String serialize(Object dataFetcherResult) {
                return dataFetcherResult != null ? dataFetcherResult.toString() : null;
            }
            @Override
            public String parseValue(Object input) {
                String str = input.toString();
                try {
                    new BigDecimal(str);
                } catch (NumberFormatException e) {

View on GitHub (pinned to 62ff490619)

Solutions

  1. Send the bare numeric literal: f(x: 1.5) or f(x: 2)
  2. Pass dynamic values as $variables typed AWSFloat
  3. Fix the query builder so numbers are not stringified
  4. Check for accidental boolean/null literals from templating conditionals

Example fix

# before
query { stats(ratio: "0.75") }

# after
query { stats(ratio: 0.75) }
Defensive patterns

Strategy: type-guard

Validate before calling

static String floatLiteral(double v) { return String.valueOf(v); } // renders unquoted 1.5 or 2.0
static String floatLiteral(Number n) { if (!(n instanceof Double || n instanceof Integer)) throw new IllegalArgumentException("AWSFloat literal must be numeric"); return n.toString(); }

Type guard

const isAwsFloatLiteral = (v: unknown): boolean => typeof v === 'number' && !Number.isNaN(v);

Try / catch

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

Prevention

When it happens

Trigger: A query document contains f(x: "1.5"), f(x: true), or f(x: null) where the argument is typed AWSFloat.

Common situations: Quoted numbers from template engines; JSON payload pasted as inline arguments; boolean/null sentinels where a number was intended; codegen rendering all values as strings.

Related errors


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