{"record":{"id":"4bd4a65d648bbd0d","repo":"microsoft/aspire","slug":"value-value-is-not-a-valid-guid","errorCode":null,"errorMessage":"Value '{value}' is not a valid GUID.","messagePattern":"Value '(.+?)' is not a valid GUID\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Radius/CloudProviders/CloudProviderValidation.cs","lineNumber":21,"sourceCode":"\nusing System.Text.RegularExpressions;\n\nnamespace Aspire.Hosting.Radius.CloudProviders;\n\n/// <summary>\n/// Lightweight syntactic validators for cloud-provider configuration inputs.\n/// Each helper throws <see cref=\"ArgumentException\"/> with\n/// <c>paramName</c> set so callers get the offending parameter in the\n/// thrown message without bespoke wrapping at every call site.\n/// </summary>\ninternal static partial class CloudProviderValidation\n{\n    internal static void ValidateGuid(string value, string paramName)\n    {\n        ArgumentException.ThrowIfNullOrEmpty(value, paramName);\n        if (!Guid.TryParse(value, out _))\n        {\n            throw new ArgumentException($\"Value '{value}' is not a valid GUID.\", paramName);\n        }\n    }\n\n    internal static void ValidateNonEmpty(string value, string paramName)\n        => ArgumentException.ThrowIfNullOrEmpty(value, paramName);\n\n    internal static void ValidateAwsAccountId(string value, string paramName)\n    {\n        ArgumentException.ThrowIfNullOrEmpty(value, paramName);\n        if (!AwsAccountIdPattern().IsMatch(value))\n        {\n            throw new ArgumentException(\n                $\"AWS account ID '{value}' must be exactly 12 digits.\", paramName);\n        }\n    }\n\n    internal static void ValidateIamRoleArn(string value, string paramName)\n    {","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Radius/CloudProviders/CloudProviderValidation.cs#L3-L39","documentation":"CloudProviderValidation.ValidateGuid checks that a cloud provider identifier string is a parseable GUID. Empty/null values are rejected by ThrowIfNullOrEmpty, and non-GUID strings throw ArgumentException(\"Value '{value}' is not a valid GUID.\") with the parameter name. Radius cloud provider registrations require GUID-shaped IDs.","triggerScenarios":"Registering/configuring a Radius cloud provider (e.g. via WithAzureCloudProvider-style APIs) passing a value that is not a valid GUID to a parameter validated by ValidateGuid.","commonSituations":"Copying an ID with surrounding whitespace or braces that don't parse; passing a subscription or resource name instead of a GUID; truncating or hand-editing an ID; using a placeholder value from documentation.","solutions":["Pass a valid GUID string, e.g. 'd5a4f3b2-1c9e-4f8a-9b7d-2e6c8a1f0b3c'.","Verify the source of the value (e.g. Azure portal / CLI output) and copy it exactly.","Trim whitespace/quotes and remove surrounding braces if present (Guid.TryParse accepts braces, but verify your value parses).","Test the value locally with Guid.TryParse before wiring it into configuration."],"exampleFix":"// before\nValidateGuid(\"my-tenant-id\", nameof(tenantId));\n\n// after\nValidateGuid(\"d5a4f3b2-1c9e-4f8a-9b7d-2e6c8a1f0b3c\", nameof(tenantId));","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(value) || !Guid.TryParse(value, out _))\n{\n    throw new ArgumentException($\"Value '{value}' is not a valid GUID.\", paramName);\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    providerBuilder.WithTenantId(tenantId);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"not a valid GUID\"))\n{\n    logger.LogError(\"Tenant ID '{Value}' is not a GUID\", tenantId);\n    throw;\n}","preventionTips":["Copy IDs directly from Azure CLI/portal output without edits.","Pre-validate values with Guid.TryParse in configuration loading code.","Keep IDs in user secrets/config rather than hardcoding placeholders."],"tags":["radius","validation","guid","cloud-providers"],"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-21T04:17:39.646Z"}