floci-io/floci · error · CoercingParseValueException
Invalid AWSBigDecimal: {}
Error message
Invalid AWSBigDecimal: {} What it means
Thrown by the AWSBigDecimal scalar's parseValue when the string cannot construct a java.math.BigDecimal. The scalar is string-based on the wire, so the numeric text must be a valid Java decimal literal (sign, digits, optional decimal point; no exponent-with-suffix forms Java rejects, no currency symbols, no separators).
Source
Thrown at src/main/java/io/github/hectorvent/floci/services/appsync/graphql/scalars/AppSyncScalars.java:402
}
})
.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) {
throw new CoercingParseValueException("Invalid AWSBigDecimal: " + str);
}
return str;
}
@Override
public String parseLiteral(Object input) {
if (input instanceof StringValue sv) return parseValue(sv.getValue());
if (input instanceof graphql.language.FloatValue fv) return fv.getValue().toString();
if (input instanceof graphql.language.IntValue iv) return iv.getValue().toString();
return null;
}
})
.build();
public static final GraphQLScalarType AWS_BIG_INT = GraphQLScalarType.newScalar()
.name("AWSBigInt")
.description("An arbitrary-precision integer")
.coercing(new Coercing<String, String>() {
@OverrideView on GitHub (pinned to 62ff490619)
Solutions
- Send the raw unformatted numeric string: "1234.56" — format for display only, never for transport
- Strip currency symbols and separators, or better, never add them: use plain toString of the BigDecimal
- For optional fields, send null/omit instead of ""
- Validate client-side: try { new BigDecimal(s); } catch before sending
Example fix
// before String price = NumberFormat.getNumberInstance(Locale.US).format(bd); // "1,234.56" -> throws // after String price = bd.toPlainString(); // "1234.56"
Defensive patterns
Strategy: validation
Validate before calling
static String toAwsBigDecimal(java.math.BigDecimal bd) { return bd.toPlainString(); }
static boolean validAwsBigDecimal(String s) { try { new java.math.BigDecimal(s); return true; } catch (NumberFormatException e) { return false; } } Type guard
const isAwsBigDecimal = (s: string): boolean => /^-?\d+(\.\d+)?$/.test(s.trim());
Try / catch
catch (CoercingParseValueException e) { // re-format with toPlainString() (no grouping, no symbols) and resend } Prevention
- Transport raw numeric strings; format only for display
- Never apply locale NumberFormat before sending
- Send null (not "") for absent values
- Validate with new BigDecimal(s) client-side
When it happens
Trigger: A GraphQL request sends "1,234.56" (thousands separator), "12.34.56", "$9.99", "abc", or "" as a variable for a field typed AWSBigDecimal.
Common situations: Locale-aware formatting applied before sending (European "1.234,56" or US "1,234.56"); currency-prefixed prices from UIs; empty strings from optional form fields submitted as "" instead of null; exponent notation mismatches from different serializers.
Related errors
AI-assisted analysis of floci-io/floci@62ff490619 (2026-08-14).
Data as JSON: /api/errors/e70dcf34c00eabdc.
Report an issue: GitHub.