{"record":{"id":"396381578c559336","repo":"floci-io/floci","slug":"awslong-must-be-an-integer","errorCode":null,"errorMessage":"AWSLong must be an integer","messagePattern":"AWSLong must be an integer","errorType":"validation","errorClass":"CoercingParseLiteralException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/appsync/graphql/scalars/AppSyncScalars.java","lineNumber":310,"sourceCode":"    public static final GraphQLScalarType AWS_LONG = GraphQLScalarType.newScalar()\n        .name(\"AWSLong\")\n        .description(\"A 64-bit signed integer\")\n        .coercing(new Coercing<Long, Long>() {\n            @Override\n            public Long serialize(Object dataFetcherResult) {\n                if (dataFetcherResult == null) return null;\n                if (dataFetcherResult instanceof Number n) return n.longValue();\n                return Long.parseLong(dataFetcherResult.toString());\n            }\n            @Override\n            public Long parseValue(Object input) {\n                if (input instanceof Number n) return n.longValue();\n                return Long.parseLong(input.toString());\n            }\n            @Override\n            public Long parseLiteral(Object input) {\n                if (input instanceof graphql.language.IntValue iv) return iv.getValue().longValue();\n                throw new CoercingParseLiteralException(\"AWSLong must be an integer\");\n            }\n        })\n        .build();\n\n    public static final GraphQLScalarType AWS_INTEGER = GraphQLScalarType.newScalar()\n        .name(\"AWSInteger\")\n        .description(\"A 32-bit signed integer\")\n        .coercing(new Coercing<Integer, Integer>() {\n            @Override\n            public Integer serialize(Object dataFetcherResult) {\n                if (dataFetcherResult == null) return null;\n                if (dataFetcherResult instanceof Number n) return n.intValue();\n                return Integer.parseInt(dataFetcherResult.toString());\n            }\n            @Override\n            public Integer parseValue(Object input) {\n                if (input instanceof Number n) return n.intValue();\n                return Integer.parseInt(input.toString());","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/appsync/graphql/scalars/AppSyncScalars.java#L292-L328","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nmutation { setCount(n: \"12345678901\") } # string literal -> throws\n\n# after\nmutation Set($n: AWSLong!) { setCount(n: $n) }\n# variables: {\"n\": 12345678901}","handlingStrategy":"type-guard","validationCode":"// Only accept bare int literals inline; for big longs always use variables\nboolean inlineSafe = (v >= Integer.MIN_VALUE && v <= Integer.MAX_VALUE);\nString doc = inlineSafe ? \"f(n: \" + v + \")\" : null; // else build a $variable version","typeGuard":"const isInlineIntLiteral = (v: number): boolean => Number.isInteger(v) && v >= -2147483648 && v <= 2147483647;","tryCatchPattern":"catch (CoercingParseLiteralException e) { // move the value into the variables map typed AWSLong and resend }","preventionTips":["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"],"tags":["graphql","appsync","awslong","parse-literal","validation"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}