{"record":{"id":"6cbacf3cf6310c9e","repo":"dotnet/orleans","slug":"invalid-blob-name","errorCode":null,"errorMessage":"Invalid blob name","messagePattern":"Invalid blob name","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Azure/Shared/Storage/AzureBlobUtils.cs","lineNumber":33,"sourceCode":"    /// </summary>\n    internal static partial class AzureBlobUtils\n    {\n        [GeneratedRegex(\"^[a-z0-9]+(-[a-z0-9]+)*$\", RegexOptions.ExplicitCapture | RegexOptions.Singleline | RegexOptions.CultureInvariant)]\n        private static partial Regex ContainerNameRegex();\n\n        internal static void ValidateContainerName(string containerName)\n        {\n            if (string.IsNullOrWhiteSpace(containerName) || containerName.Length < 3 || containerName.Length > 63 || !ContainerNameRegex().IsMatch(containerName))\n            {\n                throw new ArgumentException(\"Invalid container name\", nameof(containerName));\n            }\n        }\n\n        internal static void ValidateBlobName(string blobName)\n        {\n            if (string.IsNullOrWhiteSpace(blobName) || blobName.Length > 1024 || blobName.Count(c => c == '/') >= 254)\n            {\n                throw new ArgumentException(\"Invalid blob name\", nameof(blobName));\n            }\n        }\n    }\n}\n","sourceCodeStart":15,"sourceCodeEnd":38,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Shared/Storage/AzureBlobUtils.cs#L15-L38","documentation":"Thrown by AzureBlobUtils.ValidateBlobName when a blob name fails Azure Blob Storage naming rules: null/whitespace, longer than 1024 characters, or containing 254 or more forward-slash characters. Orleans uses blob names to address grain state and stream data, so an invalid name makes the blob address impossible to resolve. This is a hard pre-flight check that runs before any Azure call.","triggerScenarios":"Calling a code path that constructs a blob name from a null grain key, an unbounded user string, a very long composite key, or a key that embeds many '/' separators. Common with Azure Blob persistence (AzureBlobGrainStorage) and blob-based streaming providers when GrainReference.ToParcelableString or a custom key builder yields an out-of-range value.","commonSituations":"Passing an unchecked user-supplied primary key as the blob name; concatenating many key parts with '/' delimiters; upgrading grain key schemes that suddenly produce long names; null key after a deserialization bug.","solutions":["Ensure the blob name is non-null, non-blank, at most 1024 chars, and has fewer than 254 '/' characters before invoking storage.","If the name comes from a grain key, hash or truncate composite keys and avoid stacking '/' separators.","Wrap name construction in a helper that calls AzureBlobUtils.ValidateBlobName (or mirrors its rules) so invalid names fail fast in your code, not inside Orleans."],"exampleFix":"// before\nvar blobName = grainKey.ToString();   // grainKey may be null/very long\n// after\nvar raw = grainKey?.ToString() ?? throw new ArgumentNullException(nameof(grainKey));\nvar blobName = raw.Length > 1024 ? Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(raw))) : raw;\nif (blobName.Count(c => c == '/') >= 254) throw new ArgumentException(\"Blob name has too many path segments\");","handlingStrategy":"validation","validationCode":"static void EnsureValidBlobName(string name)\n{\n    if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException(\"blob name required\");\n    if (name.Length > 1024) throw new ArgumentException(\"blob name too long\");\n    if (name.Count(c => c == '/') >= 254) throw new ArgumentException(\"too many path segments\");\n}","typeGuard":"static bool IsValidBlobName(string? name) =>\n    !string.IsNullOrWhiteSpace(name) && name.Length <= 1024 && name.Count(c => c == '/') < 254;","tryCatchPattern":"catch (ArgumentException ex) when (ex.Message == \"Invalid blob name\") { /* log the offending key source and fail the grain operation */ }","preventionTips":["Centralize blob-name construction behind a validator.","Hash/truncate composite grain keys to stay under 1024 chars.","Avoid building paths with unbounded '/' segments."],"tags":["orleans","azure-storage","azure-blob","validation","argument"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}