Skip to content

Parse Last-Modified with a single-digit day - #857

Merged
andrew merged 2 commits into
git-pkgs:mainfrom
chlunde:up/maven-date-parse
Dec 1, 2026
Merged

andrew merged 2 commits into
git-pkgs:mainfrom
chlunde:up/maven-date-parse

Conversation

@chlunde

@chlunde chlunde commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

plugins.gradle.org sends Last-Modified without the leading zero on the day:

$ curl -sI https://plugins.gradle.org/m2/com/gradle/develocity/com.gradle.develocity.gradle.plugin/4.0/com.gradle.develocity.gradle.plugin-4.0.pom | grep -i last-modified
last-modified: Tue, 8 Apr 2025 19:09:23 GMT

http.ParseTime rejects that, so Maven cooldown treats a plugin version published on the 1st to 9th of a month as undated, which lets it through.

A server that runs with cooldown.default: "3650d" should reject a 1.8 year old version, but currently doesn't:

$ curl -s -o /dev/null -w "%{http_code}\n" $PROXY/maven/com/gradle/develocity/com.gradle.develocity.gradle.plugin/4.0/com.gradle.develocity.gradle.plugin-4.0.pom
200    # main (8 Apr 2025); 403 with this change

This change modifies the code to accept the unpadded day as well, both for the HEAD of a .pom, and for the time taken from a downloaded .pom.

TestMavenCooldownSingleDigitDay fails on main (200 instead of 403) and passes with this change.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed cooldown checks for upstream artifacts when modification dates use a single-digit day without a leading zero. Archive and metadata-file requests now handle this date format consistently, helping ensure artifacts remain unavailable during the correct cooldown period rather than receiving an incorrect response.

plugins.gradle.org sends Last-Modified without the leading zero on
the day ("Tue, 8 Apr 2025 19:09:23 GMT"). http.ParseTime rejects it,
so Maven cooldown treated a plugin version published on the 1st to
9th of a month as undated and let it through. Taking the time from a
downloaded .pom failed the same way, which cost an extra HEAD.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The handler now parses Last-Modified dates with an unpadded day and retains fallback parsing for other accepted HTTP date formats. Artifact observations and Maven cooldown checks use the shared parser. Tests cover JAR and POM requests.

Changes: Last-Modified parsing and Maven cooldown

Layer / File(s) Summary
Shared date parsing and cooldown checks
internal/handler/handler.go, internal/handler/maven_cooldown.go, internal/handler/maven_cooldown_test.go
A shared parser accepts unpadded-day dates and falls back to http.ParseTime. Artifact observations and POM cooldown checks use this parser. Tests cover unpadded-day dates for JAR and direct POM requests, including response status and HEAD count.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

Suggested labels: bug

Suggested reviewers: simonchrz

Merge Risk: Minimal · up to 335aa

This fix makes the Maven cooldown check recognize Last-Modified dates whose day is not zero-padded, so versions published on days 1–9 no longer slip past cooldown. The change is small and covered by a new test, and no merge-blocking risk is apparent.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Parse Last-Modified with a single-digit day" matches the main change. The PR adds parseLastModified to accept Last-Modified dates whose day has no leading zero, and uses it in pomLastModifi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Parse Last-Modified with a single-digit day" matches the main change. The PR adds parseLastModified to accept Last-Modified dates whose day has no leading zero, and uses it in pomLastModified and the upstream artifact observation path. A new test, TestMavenCooldownSingleDigitDay, covers this case. The title is concise, specific, and does not include noise.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e7fb4037-f499-4f0a-81fa-fdad7b9ade08
Commits

Reviewing files that changed from the base of the PR and between e03d8d5 and 335aacf.

Files selected for processing: 1

  • internal/handler/maven_cooldown_test.go
Files with no reviewable changes: 1

  • internal/handler/maven_cooldown_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@andrew
andrew merged commit 1c92051 into git-pkgs:main Dec 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants