{"record":{"id":"fa2018cbb2861b59","repo":"microsoft/aspire","slug":"aws-account-id-value-must-be-exactly-12-digits","errorCode":null,"errorMessage":"AWS account ID '{value}' must be exactly 12 digits.","messagePattern":"AWS account ID '(.+?)' must be exactly 12 digits\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Radius/CloudProviders/CloudProviderValidation.cs","lineNumber":33,"sourceCode":"{\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    {\n        ArgumentException.ThrowIfNullOrEmpty(value, paramName);\n        if (!IamRoleArnPattern().IsMatch(value))\n        {\n            throw new ArgumentException(\n                $\"IAM role ARN '{value}' is not in the expected form 'arn:aws:iam::<account>:role/<name>' (an optional path segment is allowed, e.g. 'arn:aws:iam::<account>:role/<path>/<name>').\",\n                paramName);\n        }\n    }\n\n    [GeneratedRegex(@\"^\\d{12}$\")]\n    private static partial Regex AwsAccountIdPattern();\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Radius/CloudProviders/CloudProviderValidation.cs#L15-L51","documentation":"CloudProviderValidation.ValidateAwsAccountId enforces that an AWS account ID is exactly 12 digits (matched by AwsAccountIdPattern). Null/empty values are rejected first, then values failing the regex throw ArgumentException(\"AWS account ID '{value}' must be exactly 12 digits.\").","triggerScenarios":"Configuring a Radius AWS cloud provider with an account ID string that is not exactly 12 numeric characters (too short, too long, containing letters, dashes, or spaces).","commonSituations":"Confusing account ID with access key ID (20 chars, starts with AKIA), ARN, or role name; pasting an ID with hyphens or whitespace; using a masked/truncated ID from logs.","solutions":["Provide the 12-digit numeric account ID, e.g. '123456789012'.","Retrieve it with 'aws sts get-caller-identity --query Account --output text'.","Strip formatting like '1234-5678-9012' or spaces before passing the value.","Confirm you are not accidentally using an access key or ARN in the account-ID field."],"exampleFix":"// before\nValidateAwsAccountId(\"AKIAIOSFODNN7EXAMPLE\", nameof(accountId));\n\n// after\nValidateAwsAccountId(\"123456789012\", nameof(accountId));","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(accountId) || !System.Text.RegularExpressions.Regex.IsMatch(accountId, @\"^\\d{12}$\"))\n{\n    throw new ArgumentException($\"AWS account ID '{accountId}' must be exactly 12 digits.\", nameof(accountId));\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    providerBuilder.WithAwsAccountId(accountId);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"12 digits\"))\n{\n    logger.LogError(\"'{Value}' is not a valid AWS account ID\", accountId);\n    throw;\n}","preventionTips":["Fetch the account ID via 'aws sts get-caller-identity' rather than typing it.","Do not confuse account IDs with access keys (AKIA...) or ARNs.","Store the ID in configuration unformatted (no dashes or spaces)."],"tags":["radius","aws","validation","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"}