{"record":{"id":"8f6e3520bce78cb3","repo":"dotnet/orleans","slug":"unexpected-exception-type-exception-gettype-ful","errorCode":null,"errorMessage":"Unexpected exception type {exception.GetType().FullName}","messagePattern":"Unexpected exception type (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Azure/Shared/Storage/AzureTableUtils.cs","lineNumber":226,"sourceCode":"            // Remove any characters that can't be used in Azure PartitionKey or RowKey values\n            // http://www.jamestharpe.com/web-development/azure-table-service-character-combinations-disallowed-in-partitionkey-rowkey/\n            key = key\n                .Replace('/', '_')        // Forward slash\n                .Replace('\\\\', '_')       // Backslash\n                .Replace('#', '_')        // Pound sign\n                .Replace('?', '_');       // Question mark\n\n            if (key.Length >= 1024)\n                throw new ArgumentException(string.Format(\"Key length {0} is too long to be an Azure table key. Key={1}\", key.Length, key));\n\n            return key;\n        }\n\n        internal static string PrintStorageException(Exception exception)\n        {\n            if (exception is not RequestFailedException storeExc)\n            {\n                throw new ArgumentException($\"Unexpected exception type {exception.GetType().FullName}\");\n            }\n\n            return $\"Message = {storeExc.Message}, HTTP Status = {storeExc.Status}, HTTP Error Code = {storeExc.ErrorCode}.\";\n        }\n\n        internal static string PointQuery(string partitionKey, string rowKey)\n        {\n            return TableClient.CreateQueryFilter($\"(PartitionKey eq {partitionKey}) and (RowKey eq {rowKey})\");\n        }\n\n        internal static string RangeQuery(string partitionKey, string minRowKey, string maxRowKey)\n        {\n            return TableClient.CreateQueryFilter($\"((PartitionKey eq {partitionKey}) and (RowKey ge {minRowKey})) and (RowKey le {maxRowKey})\");\n        }\n\n    }\n}\n","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Shared/Storage/AzureTableUtils.cs#L208-L244","documentation":"ArgumentException from AzureTableUtils.PrintStorageException when the supplied exception is not a RequestFailedException (the Azure SDK's unified failure type). The helper expects to format Message/Status/ErrorCode from RequestFailedException; anything else is a programming contract violation and is rejected.","triggerScenarios":"Passing a non-Azure exception (TimeoutException, OperationCanceledException, SerializationException, etc.) to PrintStorageException. This usually happens in a catch block that assumed the caught exception was from the storage SDK.","commonSituations":"A catch (Exception ex) that feeds ex into PrintStorageException without first checking the type, or after a dependency upgrade changed which exception type the SDK throws (e.g. older WindowsAzure.Storage threw StorageException; the current Azure.Data.Tables throws RequestFailedException). Mismatched SDK versions.","solutions":["Type-check before calling: if (exc is RequestFailedException rfe) PrintStorageException(rfe); else exc.ToString().","Confirm the Azure.Data.Tables SDK version referenced matches what Orleans expects; a stale StorageException-throwing library will never match.","Do not route OperationCanceledException or generic exceptions through this formatter."],"exampleFix":"// before\nvar detail = AzureTableUtils.PrintStorageException(ex); // throws if not RequestFailedException\n\n// after\nvar detail = ex is RequestFailedException rfe\n    ? AzureTableUtils.PrintStorageException(rfe)\n    : ex.ToString();","handlingStrategy":"type-guard","validationCode":"var detail = exc is RequestFailedException rfe\n    ? AzureTableUtils.PrintStorageException(rfe)\n    : exc.ToString();","typeGuard":"static bool IsAzureStorageException(Exception ex) => ex is RequestFailedException;","tryCatchPattern":"try { /* azure op */ }\ncatch (RequestFailedException ex) { Log(AzureTableUtils.PrintStorageException(ex)); throw; }\ncatch (Exception ex) { Log(ex.ToString()); throw; }","preventionTips":["Type-check before formatting","Keep the Azure.Data.Tables SDK version aligned with Orleans","Never feed OperationCanceledException into PrintStorageException"],"tags":["type-mismatch","azure-storage","error-handling","versioning"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}