floci-io/floci · error · CoercingParseLiteralException
AWSShort must be an integer
Error message
AWSShort must be an integer
What it means
Thrown by the AWSShort scalar's parseLiteral when the inline literal in the query document is not an IntValue (string, float, boolean, or null literal). Like the other integer scalars, AWSShort requires a bare integer literal in the document text, then range-checks it via parseValue.
Source
Thrown at src/main/java/io/github/hectorvent/floci/services/appsync/graphql/scalars/AppSyncScalars.java:359
.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());
if (val < -32768 || val > 32767)
throw new CoercingParseValueException("AWSShort out of range: " + val);
return val;
}
@Override
public Integer parseLiteral(Object input) {
if (input instanceof graphql.language.IntValue iv) return parseValue(iv.getValue().intValue());
throw new CoercingParseLiteralException("AWSShort must be an integer");
}
})
.build();
public static final GraphQLScalarType AWS_FLOAT = GraphQLScalarType.newScalar()
.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());View on GitHub (pinned to 62ff490619)
Solutions
- Use a bare integer literal: f(s: 100)
- Ensure interpolated shorts skip the string-quoting path in template code
- Pass via $variable typed AWSShort for dynamic values
- Lint documents: quoted numerics on AWSShort arguments are always wrong
Example fix
# before
query { device(mode: "100") }
# after
query { device(mode: 100) } Defensive patterns
Strategy: type-guard
Validate before calling
static String shortLiteral(Object v) {
if (v instanceof Integer i && i >= -32768 && i <= 32767) return i.toString();
throw new IllegalArgumentException("AWSShort literal must be a bare int in [-32768, 32767]");
} Type guard
const isAwsShortLiteral = (v: unknown): boolean => Number.isInteger(v) && v >= -32768 && v <= 32767;
Try / catch
catch (CoercingParseLiteralException e) { // unquote the literal, re-range-check, resend } Prevention
- Never quote short values in documents
- Prefer variables typed AWSShort
- Lint documents for quoted numerics on scalar arguments
When it happens
Trigger: A query document contains f(s: "100"), f(s: 100.0), or f(s: null) for an argument typed AWSShort.
Common situations: Query-builders quoting all interpolations; JSON-derived documents with quoted numbers; float literals from calculators/ratios; copy-paste from variable JSON into the document body.
Related errors
- AWSTimestamp must be an integer
- AWSBoolean must be a boolean literal
- AWSLong must be an integer
- AWSInteger must be an integer
- AWSShort out of range: {}
AI-assisted analysis of floci-io/floci@62ff490619 (2026-08-14).
Data as JSON: /api/errors/06ea3790b163afb4.
Report an issue: GitHub.