Skip to content

Commit 4b52cd3

Browse files
domdomeggclaude
andcommitted
Add explicit validation for server names with multiple slashes
The publish endpoint now validates that server names contain exactly one forward slash before processing. This provides a clearer error message (400 Bad Request with "server name cannot contain multiple slashes") instead of the generic 422 schema validation error. This fixes test failures where server names like: - com.example/server/path (2 slashes) - org.company/dept/team/project (3 slashes) - com.example//double-slash (consecutive slashes) - com.example/server/ (trailing slash) Should now properly return 400 with the expected error message. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent e23d4e2 commit 4b52cd3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/api/handlers/v0/publish.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ func RegisterPublishEndpoint(api huma.API, registry service.RegistryService, cfg
3434
{"bearer": {}},
3535
},
3636
}, func(ctx context.Context, input *PublishServerInput) (*Response[apiv0.ServerResponse], error) {
37+
// Validate server name format (check for multiple slashes before other validations)
38+
slashCount := strings.Count(input.Body.Name, "/")
39+
if slashCount != 1 {
40+
return nil, huma.Error400BadRequest("server name cannot contain multiple slashes")
41+
}
42+
3743
// Extract bearer token
3844
const bearerPrefix = "Bearer "
3945
authHeader := input.Authorization

0 commit comments

Comments
 (0)