fix(validators): reject invalid argument types and empty positional arguments - #1583
Open
JosephDoUrden wants to merge 1 commit into
Open
fix(validators): reject invalid argument types and empty positional arguments#1583JosephDoUrden wants to merge 1 commit into
JosephDoUrden wants to merge 1 commit into
Conversation
|
Cross-validated this PR against live registry data (same protocol as the #1555 cross-validation). Disclosure: Method
Results
Together with #1555 (class A), this covers classes A–C of #1546; class D ( |
This was referenced Aug 28, 2026
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.
Summary
Publish accepts arguments that violate the schema.
validateArgumentonly checks the named branch, so atypethat is empty or outside the enum passes through, and a positional argument with neithervaluenorvalueHintalso passes. The scan in #1546 counted 52 entries with bad argument types and 8 bare positional ones, my own paging of /v0/servers found even more of the first kind. One I checked by hand:io.github.Jordan-Horner/symbols@1.0.1(empty type under packageArguments), another iscom.keyboardcrumbs/mcp@1.0.1(type "literal", still active). Every published schema version requirestypeto be "positional" or "named" and positional args to carryvalueorvalueHint. Relates to #1546, the empty repository case is #1555's, and version "latest" is already handled since #413.Change
validateArgumentbecomes a switch. Named branch unchanged. Positional now requiresvalueorvalueHint. Unknown or emptytypeis rejected. Two new errors in constants.go, referencesinvalid-argument-typeandpositional-argument-value-or-hint-required.Why not full schema validation at publish: the enhanced validation design doc gates that behind the anyOf error consolidation (Phase 3), raw anyOf failures on arguments come out as a noisy multi-error cluster. These two checks give one clean message each and are one case arm each, easy to delete at Phase 5 when schema-first lands. Until then publish and edit just agree with what /v0/validate already reports.
Heads up on two consequences: editing a stored server that still carries one of these legacy arguments will 422 until the argument is fixed, and the importer skips invalid servers with a warning, so a re-seed from a live dump drops those entries instead of failing. Also #1339 adds a check inside the named branch of the same function, whichever lands second has a small conflict to resolve there, happy to do it from my side.
Test
Tests first, they fail on main, the handler regression actually publishes an empty-type argument with 200 on main and gets 422 with the fix. On the branch: go test ./internal/... all green including the handler tests against postgres, golangci-lint v2.13.1 (what CI pins) 0 issues, make validate passes. Two existing fixtures had positional args with neither value nor valueHint, they got a valueHint since no published schema version ever allowed that shape. New error paths and references are pinned in validation_detailed_test.go.
AI Disclosure
AI assistance (Claude) was used for issue research and during development. All changes were reviewed and tested by the author.