{"id":"1868f651d8a7ffd3","repo":"spring-projects/spring-boot","slug":"is-not-within-the-valid-range-to","errorCode":null,"errorMessage":"'{}' is not within the valid range {} to {}","messagePattern":"'(.+?)' is not within the valid range (.+?) to (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/MavenBuildOutputTimestamp.java","lineNumber":92,"sourceCode":"\t * @return the parsed timestamp as an {@code Instant}, or {@code null}\n\t * @throws IllegalArgumentException if the outputTimestamp is neither ISO 8601 nor an\n\t * integer, or it's not within the valid range 1980-01-01T00:00:02Z to\n\t * 2099-12-31T23:59:59Z\n\t */\n\t@Nullable Instant toInstant() {\n\t\tif (!StringUtils.hasLength(this.timestamp)) {\n\t\t\treturn null;\n\t\t}\n\t\tif (isNumeric(this.timestamp)) {\n\t\t\treturn Instant.ofEpochSecond(Long.parseLong(this.timestamp));\n\t\t}\n\t\tif (this.timestamp.length() < 2) {\n\t\t\treturn null;\n\t\t}\n\t\ttry {\n\t\t\tInstant instant = OffsetDateTime.parse(this.timestamp).withOffsetSameInstant(ZoneOffset.UTC).toInstant();\n\t\t\tif (instant.isBefore(DATE_MIN) || instant.isAfter(DATE_MAX)) {\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\tString.format(\"'%s' is not within the valid range %s to %s\", instant, DATE_MIN, DATE_MAX));\n\t\t\t}\n\t\t\treturn instant;\n\t\t}\n\t\tcatch (DateTimeParseException pe) {\n\t\t\tthrow new IllegalArgumentException(String.format(\"Can't parse '%s' to instant\", this.timestamp));\n\t\t}\n\t}\n\n\tprivate static boolean isNumeric(String str) {\n\t\tfor (char c : str.toCharArray()) {\n\t\t\tif (!Character.isDigit(c)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/5b2dbdbb8be64415eb6552f81ff7c449c8d251e6/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/MavenBuildOutputTimestamp.java#L74-L110","documentation":"Thrown by MavenBuildOutputTimestamp.toInstant as an IllegalArgumentException when an ISO-8601 timestamp parses successfully but falls outside the legal range for reproducible archive entries: 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z. The lower bound matches the minimum that the zip/tar formats can encode; the upper bound avoids overflow in legacy archivers. The instant, the min, and the max are all interpolated into the message.","triggerScenarios":"Setting <project.build.outputTimestamp> (or a Spring Boot <outputTimestamp>) to a date before 1980 (e.g. 1970-01-01 for 'epoch') or after 2099; providing SOURCE_DATE_EPOCH-derived values as an ISO string instead of seconds; copying a historic timestamp from a migration.","commonSituations":"Teams setting outputTimestamp to 1970-01-01T00:00:00Z believing it gives reproducible builds (it is below the 1980 floor); CI injecting a build timestamp far in the past; misconfigured git-commit-id plumbing that supplies the first-commit date; date strings sourced from a system with a wrong clock.","solutions":["Use a value within the 1980-01-01T00:00:02Z .. 2099-12-31T23:59:59Z range.","For reproducible builds, prefer an integer epoch-second (e.g. the project's source date epoch) which bypasses the ISO range check via the numeric branch.","If you genuinely want 'epoch', use the integer 315532800 (1980-01-01T00:00:00Z in seconds) or above.","Check <project.build.outputTimestamp> in the POM and any parent/BOM inheritance."],"exampleFix":"// before\n<project.build.outputTimestamp>1970-01-01T00:00:00Z</project.build.outputTimestamp>\n// after — within valid range\n<project.build.outputTimestamp>1980-01-01T00:00:02Z</project.build.outputTimestamp>\n// or numeric epoch seconds (no range check)\n<project.build.outputTimestamp>315532800</project.build.outputTimestamp>","handlingStrategy":"validation","validationCode":"// Validate an ISO timestamp is within the archive-legal range before passing it\nimport java.time.Instant, java.time.OffsetDateTime, java.time.ZoneOffset;\n\nstatic final Instant MIN = Instant.parse(\"1980-01-01T00:00:02Z\");\nstatic final Instant MAX = Instant.parse(\"2099-12-31T23:59:59Z\");\n\nvoid checkRange(String isoTs) {\n    Instant i = OffsetDateTime.parse(isoTs).withOffsetSameInstant(ZoneOffset.UTC).toInstant();\n    if (i.isBefore(MIN) || i.isAfter(MAX))\n        throw new IllegalArgumentException(i + \" out of range \" + MIN + \"..\" + MAX);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["For reproducible builds, prefer integer epoch-second values (numeric branch has no range check).","If using ISO timestamps, keep them within 1980-2099.","Add a CI assertion that parses project.build.outputTimestamp."],"tags":["maven","spring-boot","outputtimestamp","reproducible-builds","configuration"],"analyzedSha":"5b2dbdbb8be64415eb6552f81ff7c449c8d251e6","analyzedAt":"2026-08-04T18:53:14.967Z","schemaVersion":2}