{"record":{"id":"e501733095fc8ea7","repo":"dotnet/orleans","slug":"journal-format-key-journalformatkey-resolved-f","errorCode":null,"errorMessage":"Journal format key '{journalFormatKey}' resolved format '{journalFormat.GetType().FullName}', but its FormatKey is '{journalFormat.FormatKey}'. Register the journal format using the same key it reports.","messagePattern":"Journal format key '(.+?)' resolved format '(.+?)', but its FormatKey is '(.+?)'\\. Register the journal format using the same key it reports\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"src/Azure/Orleans.Journaling.AzureStorage/AzureBlobJournalStorageProvider.cs","lineNumber":132,"sourceCode":"        catch (ArgumentException)\n        {\n            journalId = default;\n            return false;\n        }\n    }\n\n    private static IJournalFormat GetJournalFormat(IServiceProvider serviceProvider, string journalFormatKey)\n    {\n        var journalFormat = serviceProvider.GetKeyedService<IJournalFormat>(journalFormatKey);\n        if (journalFormat is null)\n        {\n            throw new InvalidOperationException(\n                $\"Journal format key '{journalFormatKey}' requires keyed service '{typeof(IJournalFormat).FullName}', but none was registered.\");\n        }\n\n        if (!string.Equals(journalFormat.FormatKey, journalFormatKey, StringComparison.Ordinal))\n        {\n            throw new InvalidOperationException(\n                $\"Journal format key '{journalFormatKey}' resolved format '{journalFormat.GetType().FullName}', but its {nameof(IJournalFormat.FormatKey)} is '{journalFormat.FormatKey}'. \" +\n                \"Register the journal format using the same key it reports.\");\n        }\n\n        return journalFormat;\n    }\n\n    private static string ValidateJournalFormatKey(string? journalFormatKey)\n    {\n        if (string.IsNullOrWhiteSpace(journalFormatKey))\n        {\n            throw new InvalidOperationException(\"The configured journal format key must be non-empty.\");\n        }\n\n        return journalFormatKey;\n    }\n}\n","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Journaling.AzureStorage/AzureBlobJournalStorageProvider.cs#L114-L150","documentation":"Thrown by AzureBlobJournalStorageProvider when the IJournalFormat resolved by the configured key reports a different FormatKey than the key it was registered under. This catches a registration mismatch (e.g. registered as 'json' but the format reports FormatKey 'json-v2') that would otherwise cause silent serialization incompatibility at recovery time.","triggerScenarios":"Registering an IJournalFormat under key A, where the implementation's FormatKey property returns B (A != B, ordinal comparison). The check runs in the provider constructor after resolving the service.","commonSituations":"Updating a format implementation to a new FormatKey without updating the DI registration key; registering a format with a hardcoded key that differs from the configured JournaledStateManagerOptions; copy-paste of a registration block with a stale key.","solutions":["Register the format under the exact key its FormatKey property reports: services.AddKeyedSingleton<IJournalFormat>(format.FormatKey, format).","Ensure JournaledStateManagerOptions.JournalFormatKey equals the format's FormatKey.","If the format changed its FormatKey (new version), update both the registration and configuration together."],"exampleFix":"// before\nservices.AddKeyedSingleton<IJournalFormat>(\"json\", (sp, _) => new JsonJournalFormat()); // but JsonJournalFormat.FormatKey == \"json-v2\"\n\n// after\nservices.AddKeyedSingleton<IJournalFormat>(\"json-v2\", (sp, _) => new JsonJournalFormat());\nmanagerOptions.JournalFormatKey = \"json-v2\";","handlingStrategy":"validation","validationCode":"// After registration, assert the format key matches:\nvar fmt = serviceProvider.GetRequiredKeyedService<IJournalFormat>(configuredKey);\nif (!string.Equals(fmt.FormatKey, configuredKey, StringComparison.Ordinal))\n    throw new InvalidOperationException($\"Registered key '{configuredKey}' != format.FormatKey '{fmt.FormatKey}'.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register the format under its own FormatKey to guarantee alignment.","Add a startup assertion that compares the registered key with FormatKey.","Update both registration and configuration together when bumping a format version."],"tags":["azure-blob-storage","di","journal-format","invalid-operation","startup"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}