Skip to content

fix: add ValidateSingleServer to avoid full scan in handleSingleServerByName - #1192

Draft
aniketpandey05 wants to merge 3 commits into
Kuadrant:mainfrom
aniketpandey05:fix/validate-single-server-by-name
Draft

fix: add ValidateSingleServer to avoid full scan in handleSingleServerByName#1192
aniketpandey05 wants to merge 3 commits into
Kuadrant:mainfrom
aniketpandey05:fix/validate-single-server-by-name

Conversation

@aniketpandey05

@aniketpandey05 aniketpandey05 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

handleSingleServerByName was calling ValidateAllServers() to look up a singleserver by name, which iterates every registered upstream, builds a full aggregateStatusResponse with health stats and a populated slice, then discards everything
except the one matching entry. This was already flagged by a //TODO(craig) commentin the code.

This PR introduces ValidateSingleServer(name string) on the MCPBroker interface and mcpBrokerImpl, which acquires mcpLock.RLock() and returns as soon as it findsa name match — avoiding the full scan, the wasted allocation, and the misleading"Server validation completed" log line on every single-server status request.

Summary by CodeRabbit

  • New Features
    • Added the ability to look up the status of a single upstream server by name.
    • If the server exists, its status is returned directly; if not, the request now cleanly returns a not-found response.
  • Bug Fixes
    • Improved single-server status retrieval to avoid scanning broader results and to return more consistent responses.

…rByName

Signed-off-by: rogueslasher <aniketpandey25092005@gmail.com>
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@rogueslasher, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 12 minutes and 28 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c86b4090-9cae-4f90-93b9-2e35edcdb92a

📥 Commits

Reviewing files that changed from the base of the PR and between 0da400b and 8483e82.

📒 Files selected for processing (1)
  • internal/mcp-router/response_handlers_test.go
📝 Walkthrough

Walkthrough

Adds ValidateSingleServer(name string) (upstream.ServerValidationStatus, bool) to MCPBroker and implements it on mcpBrokerImpl. handleSingleServerByName now calls that method directly and uses the returned status and boolean to choose the response.

Changes

Single-server validation refactor

Layer / File(s) Summary
ValidateSingleServer interface and implementation
internal/broker/broker.go
Adds ValidateSingleServer(name string) (upstream.ServerValidationStatus, bool) to MCPBroker and implements it on mcpBrokerImpl with a read-locked mcpServers name match.
handleSingleServerByName refactor
internal/broker/status.go
Replaces ValidateAllServers() plus manual match scanning with broker.ValidateSingleServer(serverName), keeping the 404 path and returning the single-server status on success.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

high-risk

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding ValidateSingleServer and using it to avoid a full scan in handleSingleServerByName.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@aniketpandey05

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot added the review-effort/medium Medium review effort (3): few files, moderate logic label Jun 24, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/broker/status.go`:
- Line 123: The log in handleSingleServerByName is per-request logging, not a
lifecycle event, so change the h.logger.Info call used for “Retrieved status for
specific server” to Debug while keeping the same serverName context. Locate the
logging statement in handleSingleServerByName and update the level to match the
logger.Debug guideline for /status/{name} requests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 65d61863-cbb8-4bcd-b6e9-3add91011bc4

📥 Commits

Reviewing files that changed from the base of the PR and between 4e05373 and a29268f.

📒 Files selected for processing (2)
  • internal/broker/broker.go
  • internal/broker/status.go

Comment thread internal/broker/status.go Outdated
@aniketpandey05

Copy link
Copy Markdown
Contributor Author

will fix

Signed-off-by: rogueslasher <aniketpandey25092005@gmail.com>
@aniketpandey05

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot added the high-risk Touches concurrency, auth, sessions, CRDs, ext_proc, or routing label Jun 25, 2026
Signed-off-by: rogueslasher <aniketpandey25092005@gmail.com>
@aniketpandey05

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@aniketpandey05

aniketpandey05 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@Patryk-Stefanski should i open an issue regarding this one

thank you

@Patryk-Stefanski

Copy link
Copy Markdown
Contributor

Yes, please create an issue, and we will review it once the issue is triaged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

high-risk Touches concurrency, auth, sessions, CRDs, ext_proc, or routing review-effort/medium Medium review effort (3): few files, moderate logic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants