Skip to content

Fix NuGet cooldown enforcement for listings and downloads - #340

Open
abhinavgautam01 wants to merge 3 commits into
git-pkgs:mainfrom
abhinavgautam01:fix/nuget-cooldown-339
Open

abhinavgautam01 wants to merge 3 commits into
git-pkgs:mainfrom
abhinavgautam01:fix/nuget-cooldown-339

Conversation

@abhinavgautam01

Copy link
Copy Markdown
Contributor

Closes #339

NuGet could resolve and download versions inside the configured cooldown window. Flat-container version lists were unfiltered, pinned downloads bypassed cooldown and compressed registration responses failed JSON parsing.

This change:

  • Filters flat-container version lists using publication dates from registration metadata.
  • Checks cooldown before package downloads, including cached artifacts.
  • Decodes gzip registration responses before filtering.
  • Handles registration indexes, separate pages and individual leaves.
  • Rewrites supported registration service URLs and embedded links through the proxy.
  • Preserves package and ecosystem overrides and evaluates cached metadata against the current policy.

Adds regression coverage for compressed metadata, pagination, rewritten links, cold and cached downloads, policy overrides, metadata errors and decompressed response size limits.

Validation passed:

  • Formatting and git diff --check
  • go tool golangci-lint run ./...
  • go vet ./...
  • go build ./...
  • go test -race ./...

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Registration endpoint compatibility and invalid metadata cache replacement must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Fixes NuGet cooldown enforcement for listings, metadata, and downloads.

Changes:

  • Filters versions using registration publication dates.
  • Adds gzip handling, caching, pagination, and URL rewriting.
  • Adds regression tests and configuration documentation.
File summaries
File Summary
internal/handler/nuget.go Integrates cooldown-aware NuGet routes and download checks.
internal/handler/nuget_cooldown.go Implements metadata filtering, decompression, caching, pagination, and link rewriting. Critical (1 vote): registration base URL selection may break sources exposing only semver1. Moderate (1 vote): malformed responses can replace valid cached metadata.
internal/handler/nuget_cooldown_test.go Adds comprehensive NuGet cooldown regression coverage.
docs/configuration.md Documents NuGet cooldown behavior.
Review details

Suppressed comments (1)

internal/handler/nuget_cooldown.go:54

  • FetchOrCacheMetadata caches any successful 200 response before this JSON unmarshal. If an upstream returns malformed JSON after a valid document is cached, the malformed body replaces the valid entry, this returns 502, and later requests keep reusing the unusable cached body instead of falling back to the previously usable metadata. Validate the document before replacing the cache or retain/use the previous valid entry when parsing fails.
	var document map[string]any
	if err := json.Unmarshal(body, &document); err != nil {
		return nil, fmt.Errorf("parsing NuGet metadata: %w", err)
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/handler/nuget_cooldown.go
@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

Cache finding in the review:

  • Fixed: NuGet metadata is decoded and validated before cache replacement. Malformed responses preserve usable cached data and its ETag. Added cache-preservation and recovery tests; lint and the full race-enabled suite pass.

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.

NuGet cooldown does not apply

2 participants