Collapse duplicate unregistered custom-type handling in config validation#7043
Merged
Conversation
4 tasks
Copilot
AI
changed the title
[WIP] Fix duplicate code pattern in validateCustomServerConfig
Collapse duplicate unregistered custom-type handling in config validation
Jun 5, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR simplifies validateCustomServerConfig by removing duplicate logic for handling unregistered custom server types, relying on Go’s nil-map lookup behavior to unify the error path.
Changes:
- Removed the explicit
customSchemas == nilearly return branch. - Consolidated
nilmap and missing-key handling into the existing!existsbranch.
Show a summary per file
| File | Description |
|---|---|
| internal/config/validation.go | Removes duplicate nil-check branch so unregistered custom types share one error path |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
Comment on lines
199
to
202
| // Check if custom type is registered | ||
| if customSchemas == nil { | ||
| logValidation.Printf("Custom type not registered: name=%s, type=%s (no customSchemas)", name, serverType) | ||
| return rules.UnsupportedType("type", serverType, jsonPath, "Custom server type '"+serverType+"' is not registered in customSchemas. Add the custom type to the customSchemas field or use a standard type ('stdio' or 'http')") | ||
| } | ||
|
|
||
| schemaValue, exists := customSchemas[serverType] | ||
| if !exists { | ||
| logValidation.Printf("Custom type not registered: name=%s, type=%s", name, serverType) |
Collaborator
|
@copilot address review feedback |
Contributor
Author
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.
validateCustomServerConfighad two adjacent branches that produced the samerules.UnsupportedType(...)error for the same condition in practice: the custom type was not present incustomSchemas. This change removes that duplication and keeps the unsupported custom-type error path defined in one place.Validation flow
customSchemas == nilearly return fromvalidateCustomServerConfigniland missing-key cases fall through the same!existsbranchBehavior
niland missing-entry handling equivalent, but without duplicating the error constructionCoverage
nilcustomSchemasand unregistered custom types continue to exercise the shared path