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>
This commit is contained in:
parent
4e319e81ff
commit
35b20719ee
1 changed files with 7 additions and 5 deletions
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -106,10 +105,13 @@ func ValidateOCI(ctx context.Context, pkg model.Package, serverName string) erro
|
||||||
if errors.As(err, &transportErr) {
|
if errors.As(err, &transportErr) {
|
||||||
switch transportErr.StatusCode {
|
switch transportErr.StatusCode {
|
||||||
case http.StatusTooManyRequests:
|
case http.StatusTooManyRequests:
|
||||||
// Rate limited - skip validation to avoid blocking publishers
|
// Fail closed: a 429 means we could not verify the
|
||||||
// This is intentional: we prioritize UX over strict validation during high traffic
|
// `io.modelcontextprotocol.server.name` label on the image, which is
|
||||||
log.Printf("Skipping OCI validation for %s due to rate limiting", pkg.Identifier)
|
// the only ownership proof we apply to OCI packages. Returning nil
|
||||||
return nil
|
// here would let a publisher bind their server record to an arbitrary
|
||||||
|
// public image they do not control, which is the bug this branch
|
||||||
|
// used to have. Surface the rate-limit as a retryable error instead.
|
||||||
|
return fmt.Errorf("OCI registry is currently rate-limiting validations for '%s'; please retry shortly", pkg.Identifier)
|
||||||
case http.StatusNotFound:
|
case http.StatusNotFound:
|
||||||
return fmt.Errorf("OCI image '%s' does not exist in the registry", pkg.Identifier)
|
return fmt.Errorf("OCI image '%s' does not exist in the registry", pkg.Identifier)
|
||||||
case http.StatusUnauthorized, http.StatusForbidden:
|
case http.StatusUnauthorized, http.StatusForbidden:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue