Skip to content

Commit 35b2071

Browse files
rdimitrovclaude
andauthored
fix(validators/oci): fail closed on upstream rate limiting (#1281)
## Summary When the OCI validator's anonymous manifest fetch returns HTTP 429, return a retryable error instead of `nil`. This aligns OCI with the fail-closed behavior of the npm / PyPI / NuGet / MCPB validators, and ensures the `io.modelcontextprotocol.server.name` label-match always runs before a publish is accepted. ## Test plan - [x] `go test ./internal/validators/registries/ -run TestValidateOCI` passes locally - [x] `gofmt` + `golangci-lint` clean on the changed file - [ ] CI green 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4e319e8 commit 35b2071

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

  • internal/validators/registries

internal/validators/registries/oci.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"errors"
66
"fmt"
7-
"log"
87
"net/http"
98
"strings"
109
"time"
@@ -106,10 +105,13 @@ func ValidateOCI(ctx context.Context, pkg model.Package, serverName string) erro
106105
if errors.As(err, &transportErr) {
107106
switch transportErr.StatusCode {
108107
case http.StatusTooManyRequests:
109-
// Rate limited - skip validation to avoid blocking publishers
110-
// This is intentional: we prioritize UX over strict validation during high traffic
111-
log.Printf("Skipping OCI validation for %s due to rate limiting", pkg.Identifier)
112-
return nil
108+
// Fail closed: a 429 means we could not verify the
109+
// `io.modelcontextprotocol.server.name` label on the image, which is
110+
// the only ownership proof we apply to OCI packages. Returning nil
111+
// here would let a publisher bind their server record to an arbitrary
112+
// public image they do not control, which is the bug this branch
113+
// used to have. Surface the rate-limit as a retryable error instead.
114+
return fmt.Errorf("OCI registry is currently rate-limiting validations for '%s'; please retry shortly", pkg.Identifier)
113115
case http.StatusNotFound:
114116
return fmt.Errorf("OCI image '%s' does not exist in the registry", pkg.Identifier)
115117
case http.StatusUnauthorized, http.StatusForbidden:

0 commit comments

Comments
 (0)