Fix NuGet cooldown enforcement for listings and downloads - #340
Open
abhinavgautam01 wants to merge 3 commits into
Open
abhinavgautam01 wants to merge 3 commits into
abhinavgautam01 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
🟡 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
FetchOrCacheMetadatacaches 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.
Contributor
Author
|
Cache finding in the review:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Adds regression coverage for compressed metadata, pagination, rewritten links, cold and cached downloads, policy overrides, metadata errors and decompressed response size limits.
Validation passed:
git diff --checkgo tool golangci-lint run ./...go vet ./...go build ./...go test -race ./...