Ban 'latest' as a reserved version string (#413)
## Summary - Adds validation to prevent servers from being published with version string "latest" - "latest" is now a reserved keyword that cannot be used as a version string ## Implementation - Added `ErrReservedVersionString` error constant - Created `validateVersion` function to check for reserved version strings - Integrated validation into the package field validation flow - Added comprehensive test coverage --- This is so we can potentially support things like https://github.com/modelcontextprotocol/registry/discussions/333 in future more easily, as I imagine we might want to.
This commit is contained in:
parent
64b7fc6408
commit
41aacc1846
1 changed files with 45 additions and 5 deletions
|
|
@ -193,6 +193,30 @@ func TestValidate(t *testing.T) {
|
|||
},
|
||||
expectedError: validators.ErrPackageNameHasSpaces.Error(),
|
||||
},
|
||||
{
|
||||
name: "package with reserved version 'latest'",
|
||||
serverDetail: apiv0.ServerJSON{
|
||||
Name: "com.example/test-server",
|
||||
Description: "A test server",
|
||||
Repository: model.Repository{
|
||||
URL: "https://github.com/owner/repo",
|
||||
Source: "github",
|
||||
},
|
||||
Version: "1.0.0",
|
||||
Packages: []model.Package{
|
||||
{
|
||||
Identifier: "test-package",
|
||||
RegistryType: "npm",
|
||||
RegistryBaseURL: "https://registry.npmjs.org",
|
||||
Version: "latest",
|
||||
Transport: model.Transport{
|
||||
Type: "stdio",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: validators.ErrReservedVersionString.Error(),
|
||||
},
|
||||
{
|
||||
name: "multiple packages with one invalid",
|
||||
serverDetail: apiv0.ServerJSON{
|
||||
|
|
|
|||
Loading…
Reference in a new issue