{"record":{"id":"7c80b25eb74b32b8","repo":"floci-io/floci","slug":"awstimestamp-out-of-range","errorCode":null,"errorMessage":"AWSTimestamp out of range: {}","messagePattern":"AWSTimestamp 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":153,"sourceCode":"        .build();\n\n    public static final GraphQLScalarType AWS_TIMESTAMP = GraphQLScalarType.newScalar()\n        .name(\"AWSTimestamp\")\n        .description(\"Unix epoch seconds (0 to 32503680000)\")\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                long val;\n                if (input instanceof Number n) val = n.longValue();\n                else val = Long.parseLong(input.toString());\n                if (val < 0 || val > 32503680000L)\n                    throw new CoercingParseValueException(\"AWSTimestamp out of range: \" + val);\n                return val;\n            }\n            @Override\n            public Long parseLiteral(Object input) {\n                if (input instanceof graphql.language.IntValue iv) return parseValue(iv.getValue().longValue());\n                throw new CoercingParseLiteralException(\"AWSTimestamp must be an integer\");\n            }\n        })\n        .build();\n\n    private static final Pattern EMAIL_PATTERN = Pattern.compile(\"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,}$\");\n\n    public static final GraphQLScalarType AWS_EMAIL = GraphQLScalarType.newScalar()\n        .name(\"AWSEmail\")\n        .description(\"An RFC 5322 email address\")\n        .coercing(new Coercing<String, String>() {\n            @Override\n            public String serialize(Object dataFetcherResult) {","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/appsync/graphql/scalars/AppSyncScalars.java#L135-L171","documentation":"Thrown by the AWSTimestamp scalar's parseValue when the integer falls outside the allowed epoch-seconds window [0, 32503680000] (year 1 to year 3000 CE). AppSync defines AWSTimestamp as a numeric scalar with that validity range, and the emulator enforces it after converting the input to a long.","triggerScenarios":"A GraphQL request sends a negative epoch (e.g. -1), an epoch in milliseconds (e.g. 1705315800000 which is > 32503680000 and thus out of range for seconds), or a far-future value beyond year 3000 as an AWSTimestamp variable.","commonSituations":"Mixing up epoch milliseconds and epoch seconds — millis values exceed the ceiling immediately; clock skew or an uninitialized long (0 is fine but -1 from an error code is not); garbage values from uninitialized numeric fields or a default -1 sentinel.","solutions":["Send epoch SECONDS: Instant.now().getEpochSecond(), never System.currentTimeMillis()","If you have millis, divide by 1000: millis / 1000","Clamp sentinels: use null or omit the field instead of -1 for 'no value'","Validate client-side: 0 <= v && v <= 32503680000L"],"exampleFix":"// before\nlong ts = System.currentTimeMillis(); // 1.7e12 -> out of range\n\n// after\nlong ts = Instant.now().getEpochSecond(); // ~1.7e9, in range","handlingStrategy":"type-guard","validationCode":"static boolean validAwsTimestamp(long v) { return v >= 0 && v <= 32503680000L; }\nlong ts = Instant.now().getEpochSecond();\nif (!validAwsTimestamp(ts)) throw new IllegalArgumentException(\"timestamp must be epoch seconds in [0, 32503680000]\");","typeGuard":"const isAwsTimestamp = (v: number): boolean => Number.isInteger(v) && v >= 0 && v <= 32503680000;","tryCatchPattern":"catch (CoercingParseValueException e) { // usually a millis/seconds mixup: divide by 1000 and retry once }","preventionTips":["Standardize on epoch seconds everywhere in the client","Wrap System.currentTimeMillis() callers: timestamp = millis / 1000","Never use -1 sentinels for AWSTimestamp — omit the field instead"],"tags":["graphql","appsync","awstimestamp","epoch","validation"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}