Simplify EndpointValidator handling of allowed suffixes#2329
Simplify EndpointValidator handling of allowed suffixes#2329alzimmermsft wants to merge 4 commits intomicrosoft:mainfrom
Conversation
jongio
left a comment
There was a problem hiding this comment.
Two issues block this PR:
1. Subdomain matching broken
GetSuffixForEnvironment returns bare domains (azconfig.io) but the unchanged validation lambda checks suffix.StartsWith('.') for subdomain matching. Since the leading dot is gone, that branch never executes - every subdomain endpoint like myconfig.azconfig.io gets rejected. Only exact domain matches pass, which no real Azure service uses. This is almost certainly what's causing the 4 CI failures.
2. Error message regression
string.Join(", ", allowedSuffixes) now operates on IEnumerable<AllowedSuffixManager>, so it'll print the record's ToString() (all four cloud variants) instead of clean domain strings.
Suggested fix for both - resolve suffixes into a string array before the validation and error paths:
var resolvedSuffixes = allowedSuffixes
.Select(s => $".{s.GetSuffixForEnvironment(armEnvironment)}")
.ToArray();
var isValid = resolvedSuffixes.Any(suffix =>
{
// existing lambda unchanged
});
// in error path:
$"Expected domains: {string.Join(\", \", resolvedSuffixes)}"Minor: IEnumerable<AllowedSuffixManager> could be AllowedSuffixManager[] for better AOT clarity.
There was a problem hiding this comment.
Pull request overview
This PR refactors EndpointValidator’s Azure-service allowed-domain suffix handling to a more data-driven structure, aiming to make sovereign cloud suffix selection clearer and easier to extend.
Changes:
- Replaced per-call suffix dictionary construction with a static suffix map keyed by service type.
- Introduced an
AllowedSuffixManagerrecord to resolve suffixes based onArmEnvironment. - Updated validation logic to resolve environment-specific suffixes before performing host checks and error reporting.
What does this PR do?
Cleans up the design of
EndpointValidatorto make suffix handling clearer and easier to extend in the future.GitHub issue number?
[Link to the GitHub issue this PR addresses]Pre-merge Checklist
servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentationREADME.mdchanges running the script./eng/scripts/Process-PackageReadMe.ps1. See Package READMEToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test promptsconsolidated-tools.jsonbreaking-changelabelservers/Azure.Mcp.Server/docs/azmcp-commands.md./eng/scripts/Update-AzCommandsMetadata.ps1to update tool metadata inazmcp-commands.md(required for CI)servers/Azure.Mcp.Server/docs/e2eTestPrompts.mdcrypto mining, spam, data exfiltration, etc.)/azp run mcp - pullrequest - liveto run Live Test Pipeline