{"record":{"id":"ac4472b719bf67e9","repo":"microsoft/aspire","slug":"at-least-one-connector-operation-must-be-explicitly-allow","errorCode":null,"errorMessage":"At least one connector operation must be explicitly allow-listed.","messagePattern":"At least one connector operation must be explicitly allow-listed\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.ConnectorNamespace/AzureConnectorNamespaceExtensions.cs","lineNumber":609,"sourceCode":"                $\"Existing MCP server configuration '{builder.Resource.Name}' is read-only.\");\n        }\n\n        if (!ReferenceEquals(builder.Resource.Parent, connection.Resource.Parent))\n        {\n            throw new InvalidOperationException(\n                $\"Connector connection '{connection.Resource.Name}' belongs to a different Connector Namespace.\");\n        }\n\n        if (builder.Resource.Connectors.Count > 0)\n        {\n            throw new InvalidOperationException(\n                $\"MCP server configuration '{builder.Resource.Name}' already has a connector. \" +\n                \"The current Connector Namespace preview supports one connector per MCP server configuration.\");\n        }\n\n        if (options.Operations is null || options.Operations.Length == 0)\n        {\n            throw new ArgumentException(\n                \"At least one connector operation must be explicitly allow-listed.\",\n                nameof(options));\n        }\n\n        var operationNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\n        var connectorDefinition = new AzureConnectorNamespaceMcpConnectorDefinition(\n            connectorName,\n            options.DisplayName,\n            options.Description,\n            connection.Resource);\n        foreach (var operation in options.Operations)\n        {\n            if (operation is null)\n            {\n                throw new ArgumentException(\"Connector operations cannot contain null values.\", nameof(options));\n            }\n\n            ArgumentException.ThrowIfNullOrWhiteSpace(operation.Name);","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.ConnectorNamespace/AzureConnectorNamespaceExtensions.cs#L591-L627","documentation":"WithConnector requires the connector options to explicitly allow-list at least one operation. The library throws this ArgumentException when options.Operations is null or an empty array because a connector definition with no operations would be meaningless in the MCP connector model.","triggerScenarios":"Calling WithConnector(...) on an MCP server configuration with options.Operations set to null or to an empty array (e.g. new AzureConnectorNamespaceConnectorOptions { Operations = Array.Empty<...>() } or simply omitting Operations).","commonSituations":"Developers building connector options dynamically and forgetting to populate the operations collection; copying a sample and deleting the Operations entry; conditional code paths that skip adding operations.","solutions":["Add at least one operation to options.Operations before calling WithConnector, e.g. Operations = new[] { new ConnectorOperation { Name = \"GetItems\" } }.","Guard your own options-construction code so Operations is never left null/empty.","If operations are conditional, validate and fail early with a clear message in your own code."],"exampleFix":"// before\nvar options = new AzureConnectorNamespaceConnectorOptions();\nbuilder.WithConnector(options);\n// after\nvar options = new AzureConnectorNamespaceConnectorOptions\n{\n    Operations = new[] { new AzureConnectorNamespaceConnectorOperation { Name = \"ReadItems\" } }\n};\nbuilder.WithConnector(options);","handlingStrategy":"validation","validationCode":"if (options?.Operations is null || options.Operations.Length == 0)\n{\n    throw new InvalidOperationException(\"Connector options must include at least one operation.\");\n}\nbuilder.WithConnector(options);","typeGuard":null,"tryCatchPattern":"try { builder.WithConnector(options); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"allow-listed\"))\n{\n    // add operations to options and retry\n}","preventionTips":["Always initialize Operations when constructing connector options.","Validate options before passing to WithConnector.","Avoid building options in code paths that can skip operation population."],"tags":["azure","connector","validation","argument"],"backgroundTag":"empty-required-field","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}