{"record":{"id":"c8544d42081cc166","repo":"microsoft/aspire","slug":"connector-namespace-resource-names-can-contain-only-ascii","errorCode":null,"errorMessage":"Connector Namespace resource names can contain only ASCII letters, numbers, hyphens, and underscores.","messagePattern":"Connector Namespace resource names can contain only ASCII letters, numbers, hyphens, and underscores\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.ConnectorNamespace/AzureConnectorNamespaceExtensions.cs","lineNumber":765,"sourceCode":"        }\n    }\n\n    private static void ValidateConnectorResourceName(string name, string paramName)\n    {\n        ArgumentException.ThrowIfNullOrWhiteSpace(name, paramName);\n        if (name.Length is < 2 or > 64)\n        {\n            throw new ArgumentOutOfRangeException(\n                paramName,\n                name,\n                \"Connector Namespace resource names must contain between 2 and 64 characters.\");\n        }\n\n        if (name.Any(static character =>\n            !char.IsAsciiLetterOrDigit(character) &&\n            character is not '-' and not '_'))\n        {\n            throw new ArgumentException(\n                \"Connector Namespace resource names can contain only ASCII letters, numbers, hyphens, and underscores.\",\n                paramName);\n        }\n    }\n\n}\n","sourceCodeStart":747,"sourceCodeEnd":772,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.ConnectorNamespace/AzureConnectorNamespaceExtensions.cs#L747-L772","documentation":"Connector Namespace resource names must use only ASCII letters, digits, hyphens, and underscores; Azure rejects any other character. ValidateConnectorResourceName throws ArgumentException naming the offending parameter when any character falls outside this set.","triggerScenarios":"Passing a name containing spaces, dots, slashes, or non-ASCII/Unicode characters to AddConnection, WithAccessPolicy, WithIdentityAccessPolicy, or AddMcpServerConfig.","commonSituations":"Deriving names from project paths or URLs (dots/slashes), using localized or emoji characters, copying names with trailing spaces or casing artifacts.","solutions":["Remove or replace disallowed characters (e.g. '.' -> '-')","Use a sanitizer that maps the name to [A-Za-z0-9_-] only","Avoid deriving names directly from paths, URLs, or user input"],"exampleFix":"// before\n.AddConnection(\"my app.conn\", ...)\n// after\n.AddConnection(\"my-app-conn\", ...)","handlingStrategy":"validation","validationCode":"if (name.Any(c => !char.IsAsciiLetterOrDigit(c) && c is not '-' and not '_'))\n    throw new ArgumentException(\"Name must contain only ASCII letters, digits, '-', '_'.\", nameof(name));","typeGuard":null,"tryCatchPattern":"try { builder.AddConnection(name, ...); }\ncatch (ArgumentException ex) { log.LogError(ex, \"Name contains invalid characters\"); }","preventionTips":["Sanitize names derived from paths/URLs/user input","Use a canonical slug function for all resource names","Avoid non-ASCII identifiers in infrastructure code"],"tags":["azure","validation","naming","ascii"],"backgroundTag":"invalid-identifier-format","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}