Repository navigation
Unify submission validation and versioned route registration - #1935
Merged
Merged
Conversation
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>
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.
Follow up on #1926, #1928, #1932, and #1933 so submission rules, config-driven validation flags, and versioned routes each have a single definition.
Change
ValidateWriteRequest): Replace the separateValidatePublishRequestandValidateUpdateRequestentry points soCreateServerandUpdateServershare one write-validation path. Deleted-version updates continue to skip outbound checks viaskipRegistryValidationwhile enforcing local submission limits.validateWritePreflight): Run local submission limits from a single helper called by bothValidateServerJSON(/validate, collecting all issues) andValidateWriteRequest(publish and edit, stopping at the first issue). Alongside the existing record, nested-string, and publisher-metadata byte caps,/validatenow also reports the 16-distinct-package ownership check limit (package-ownership-limit) and 32-unique-remote-hostname limit (remote-host-lookup-limit) whenEnableRegistryValidationis enabled, with zero outbound network calls.ValidationIssueretains the underlying error soFirstError()preserves error unwrapping (errors.Is) and HTTP 400 diagnostics on writes.ValidationOptions.WithConfig(cfg)across/publish, edit,/validate, and seed import, and register/v0and/v0.1from one shared route list inrouter.RegisterRoutes.Verification
internal/validators/preflight_internal_test.goandinternal/api/router/parity_test.gocovering/v0and/v0.1across/validate,/publish, andPUTedit withEnableRegistryValidationboth enabled and disabled.registryinstances (ENABLE_REGISTRY_VALIDATION=true,ENABLE_REGISTRY_VALIDATION=false, andALLOW_PRIVATE_REMOTE_URLS=true) plusmcp-publisheragainst isolated PostgreSQL 17:4,096/4,097nested UTF-8 and metadata bytes,131,072/131,073serialized record bytes,32/33unique remote hostnames, and17distinct packages) and multi-issue payloads (/validatereturns all three preflight issues; writes stop at the first) across/v0and/v0.1, with zero OSV requests on preflight rejections and intact stored records on failed writes.ENABLE_REGISTRY_VALIDATION=falsewhile size caps still reject.GET, statusPATCH(deprecated,deleted,active), and a shrinkingPUT.mcp-publisher validateandmcp-publisher publishagainst the live server.go test -race ./internal/... ./cmd/... ./pkg/...,golangci-lint run(v2.14.0),make validate, andmake build.