{"record":{"id":"62232862e81836e9","repo":"floci-io/floci","slug":"awsshort-out-of-range","errorCode":null,"errorMessage":"AWSShort out of range: {}","messagePattern":"AWSShort out of range: (.+?)","errorType":"validation","errorClass":"CoercingParseValueException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/appsync/graphql/scalars/AppSyncScalars.java","lineNumber":353,"sourceCode":"        })\n        .build();\n\n    public static final GraphQLScalarType AWS_SHORT = GraphQLScalarType.newScalar()\n        .name(\"AWSShort\")\n        .description(\"A 16-bit signed integer (-32768 to 32767)\")\n        .coercing(new Coercing<Integer, Integer>() {\n            @Override\n            public Integer serialize(Object dataFetcherResult) {\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                int val;\n                if (input instanceof Number n) val = n.intValue();\n                else val = Integer.parseInt(input.toString());\n                if (val < -32768 || val > 32767)\n                    throw new CoercingParseValueException(\"AWSShort out of range: \" + val);\n                return val;\n            }\n            @Override\n            public Integer parseLiteral(Object input) {\n                if (input instanceof graphql.language.IntValue iv) return parseValue(iv.getValue().intValue());\n                throw new CoercingParseLiteralException(\"AWSShort must be an integer\");\n            }\n        })\n        .build();\n\n    public static final GraphQLScalarType AWS_FLOAT = GraphQLScalarType.newScalar()\n        .name(\"AWSFloat\")\n        .description(\"An IEEE 754 double-precision float\")\n        .coercing(new Coercing<Double, Double>() {\n            @Override\n            public Double serialize(Object dataFetcherResult) {\n                if (dataFetcherResult == null) return null;\n                if (dataFetcherResult instanceof Number n) return n.doubleValue();","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/appsync/graphql/scalars/AppSyncScalars.java#L335-L371","documentation":"Thrown by the AWSShort scalar's parseValue when the integer, after conversion, falls outside the 16-bit signed range [-32768, 32767]. The scalar first coerces the input to an int (accepting numbers or numeric strings), then enforces the short range explicitly.","triggerScenarios":"A GraphQL request sends 65535, -40000, 100000, or \"70000\" as a variable for a field typed AWSShort.","commonSituations":"Reusing an int-typed client model field for a schema field declared AWSShort; computed values (counts, quantities, ports above 32767) overflowing the narrow type; porting data from systems using unsigned 16-bit semantics (0-65535); test fixtures using large sentinel numbers.","solutions":["Clamp or range-check the value client-side before sending: -32768 <= v && v <= 32767","If legit values exceed 32767, widen the schema field to AWSInteger/AWSLong","Map unsigned-16 sources by down-shifting or validating (< 65536) explicitly","Add a boundary test for 32767/32768 to catch regressions"],"exampleFix":"// before\nvariables.put(\"port\", 65535); // > 32767 -> throws\n\n// after\nif (port < -32768 || port > 32767) throw new IllegalArgumentException(\"port out of short range\");\nvariables.put(\"port\", port);","handlingStrategy":"validation","validationCode":"static int toAwsShort(int v) {\n    if (v < -32768 || v > 32767) throw new IllegalArgumentException(\"AWSShort out of range: \" + v);\n    return v;\n}","typeGuard":"const isAwsShort = (v: number): boolean => Number.isInteger(v) && v >= -32768 && v <= 32767;","tryCatchPattern":"catch (CoercingParseValueException e) { // clamp or widen: change schema field to AWSInteger if 32767 is too small }","preventionTips":["Range-check at the client boundary","Model client fields with the same width as the schema","Add boundary tests at 32767/32768 and -32768/-32769"],"tags":["graphql","appsync","awsshort","range","validation"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}