Skip to content

Unify submission validation and versioned route registration - #1935

Merged
rdimitrov merged 2 commits into
mainfrom
rdimitrov-unify-submission-validation
Nov 27, 2026
Merged

rdimitrov merged 2 commits into
mainfrom
rdimitrov-unify-submission-validation

Conversation

@rdimitrov

@rdimitrov rdimitrov commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Follow up on #1926, #1928, #1932, and #1933 so submission rules, config-driven validation flags, and versioned routes each have a single definition.

Change

  • Single write validator (ValidateWriteRequest): Replace the separate ValidatePublishRequest and ValidateUpdateRequest entry points so CreateServer and UpdateServer share one write-validation path. Deleted-version updates continue to skip outbound checks via skipRegistryValidation while enforcing local submission limits.
  • Shared local preflight (validateWritePreflight): Run local submission limits from a single helper called by both ValidateServerJSON (/validate, collecting all issues) and ValidateWriteRequest (publish and edit, stopping at the first issue). Alongside the existing record, nested-string, and publisher-metadata byte caps, /validate now also reports the 16-distinct-package ownership check limit (package-ownership-limit) and 32-unique-remote-hostname limit (remote-host-lookup-limit) when EnableRegistryValidation is enabled, with zero outbound network calls. ValidationIssue retains the underlying error so FirstError() preserves error unwrapping (errors.Is) and HTTP 400 diagnostics on writes.
  • Single config and route wiring: Add ValidationOptions.WithConfig(cfg) across /publish, edit, /validate, and seed import, and register /v0 and /v0.1 from one shared route list in router.RegisterRoutes.

Verification

  • Added unit and cross-endpoint parity tests in internal/validators/preflight_internal_test.go and internal/api/router/parity_test.go covering /v0 and /v0.1 across /validate, /publish, and PUT edit with EnableRegistryValidation both enabled and disabled.
  • Ran live registry instances (ENABLE_REGISTRY_VALIDATION=true, ENABLE_REGISTRY_VALIDATION=false, and ALLOW_PRIVATE_REMOTE_URLS=true) plus mcp-publisher against isolated PostgreSQL 17:
    • Verified exact boundaries (4,096/4,097 nested UTF-8 and metadata bytes, 131,072/131,073 serialized record bytes, 32/33 unique remote hostnames, and 17 distinct packages) and multi-issue payloads (/validate returns all three preflight issues; writes stop at the first) across /v0 and /v0.1, with zero OSV requests on preflight rejections and intact stored records on failed writes.
    • Confirmed 17-package and 33-remote writes and validations succeed end-to-end when ENABLE_REGISTRY_VALIDATION=false while size caps still reject.
    • Seeded a legacy oversized 20-package row in PostgreSQL and verified GET, status PATCH (deprecated, deleted, active), and a shrinking PUT.
    • Verified mcp-publisher validate and mcp-publisher publish against the live server.
  • Passed go test -race ./internal/... ./cmd/... ./pkg/..., golangci-lint run (v2.14.0), make validate, and make build.

rdimitrov and others added 2 commits November 27, 2026 23:55
Consolidate overlapping validation and routing entry points so new
submission rules, config flags, and endpoints only need to be wired in
one place:

- Replace separate ValidatePublishRequest and ValidateUpdateRequest
  functions with a single ValidateWriteRequest shared by CreateServer
  and UpdateServer.
- Extract validateWritePreflight so ValidateServerJSON (/validate) and
  ValidateWriteRequest (publish and edit) share local submission size
  limits and registry-validation preflight budgets (distinct package
  ownership checks and unique remote DNS host lookups).
- Add ValidationOptions.WithConfig so publish, edit, validate, and seed
  import propagate config-driven validation flags from a single helper,
  and retain wrapped errors on ValidationIssue for FirstError callers.
- Register /v0 and /v0.1 endpoints from one shared route list in
  router.RegisterRoutes, with cross-endpoint parity tests across both
  API versions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@rdimitrov
rdimitrov merged commit e0b3fea into main Nov 27, 2026
8 checks passed
@rdimitrov
rdimitrov deleted the rdimitrov-unify-submission-validation branch November 27, 2026 23:02
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.

1 participant