<!-- Provide a brief summary of your changes --> Validates that server versions are not ranges. **NB:** This also introduces `validateVersion` as a check on the top-level `ValidateServerJSON`, as previously we were only checking version ranges of packages via `validatePackageField` (i.e. `latest` would have still been a valid top level server version), despite #413's wording suggesting otherwise. ## Motivation and Context Solves https://github.com/modelcontextprotocol/registry/issues/415 ## How Has This Been Tested? Tests added in `internal/validators/validators_test.go` `make check` is clean. ## Breaking Changes As per @domdomegg's comment, we should > check nobody has done this in the existing registry data (if they have, we should explore and understand why people have done this / if it's valid etc.). ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed ## Additional context <!-- Add any other context, implementation notes, or design decisions -->
36 lines
1.4 KiB
Go
36 lines
1.4 KiB
Go
package validators
|
|
|
|
import "errors"
|
|
|
|
// Error messages for validation
|
|
var (
|
|
// Repository validation errors
|
|
ErrInvalidRepositoryURL = errors.New("invalid repository URL")
|
|
ErrInvalidSubfolderPath = errors.New("invalid subfolder path")
|
|
|
|
// Package validation errors
|
|
ErrPackageNameHasSpaces = errors.New("package name cannot contain spaces")
|
|
ErrReservedVersionString = errors.New("version string 'latest' is reserved and cannot be used")
|
|
ErrVersionLooksLikeRange = errors.New("version must be a specific version, not a range")
|
|
|
|
// Remote validation errors
|
|
ErrInvalidRemoteURL = errors.New("invalid remote URL")
|
|
|
|
// Registry validation errors
|
|
ErrUnsupportedRegistryBaseURL = errors.New("unsupported registry base URL")
|
|
ErrMismatchedRegistryTypeAndURL = errors.New("registry type and base URL do not match")
|
|
|
|
// Argument validation errors
|
|
ErrNamedArgumentNameRequired = errors.New("named argument name is required")
|
|
ErrInvalidNamedArgumentName = errors.New("invalid named argument name format")
|
|
ErrArgumentValueStartsWithName = errors.New("argument value cannot start with the argument name")
|
|
ErrArgumentDefaultStartsWithName = errors.New("argument default cannot start with the argument name")
|
|
)
|
|
|
|
// RepositorySource represents valid repository sources
|
|
type RepositorySource string
|
|
|
|
const (
|
|
SourceGitHub RepositorySource = "github"
|
|
SourceGitLab RepositorySource = "gitlab"
|
|
)
|