{"record":{"id":"25e2daf0b1279f91","repo":"dotnet/orleans","slug":"journal-format-key-journalformatkey-resolved-f-25e2da","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/AzureTableJournalStorageProvider.cs","lineNumber":136,"sourceCode":"        catch (ArgumentException)\n        {\n            journalId = default;\n            return false;\n        }\n    }\n\n    private static void ValidateJournalFormat(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\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":118,"sourceCodeEnd":152,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Journaling.AzureStorage/AzureTableJournalStorageProvider.cs#L118-L152","documentation":"Thrown by ValidateJournalFormat when a keyed IJournalFormat was resolved, but its own FormatKey property does not match the key used to register/resolve it. The system requires the registration key and the format's self-reported key to agree, to prevent format/version mismatches that would corrupt journals.","triggerScenarios":"An IJournalFormat implementation is registered under key A but its FormatKey property returns B; ValidateJournalFormat compares them with ordinal equality and throws.","commonSituations":"Registering a format under a custom alias instead of its canonical FormatKey; a versioned format whose FormatKey changed across an upgrade but the registration key was not updated; copy-paste of a registration with the wrong key.","solutions":["Register the format using the same key that its FormatKey property reports (read the property or docs to find the canonical key).","Update the registration key to match after a format upgrade that changed FormatKey.","Avoid inventing alias keys; use the format's documented key."],"exampleFix":"// before\nservices.AddKeyedSingleton<IJournalFormat, JsonJournalFormat>('myJson'); // FormatKey is 'json'\n// after\nservices.AddKeyedSingleton<IJournalFormat, JsonJournalFormat>('json'); // matches FormatKey","handlingStrategy":"validation","validationCode":"var fmt = serviceProvider.GetRequiredKeyedService<IJournalFormat>(journalFormatKey);\nif (!string.Equals(fmt.FormatKey, journalFormatKey, StringComparison.Ordinal))\n    throw new InvalidOperationException($\"Register the format under its own FormatKey '{fmt.FormatKey}'.\");","typeGuard":"static bool KeyMatchesFormatKey(IServiceProvider sp, string key)\n    => sp.GetKeyedService<IJournalFormat>(key) is { } f && string.Equals(f.FormatKey, key, StringComparison.Ordinal);","tryCatchPattern":null,"preventionTips":["Always register an IJournalFormat under the key reported by its FormatKey property.","After a format package upgrade, re-check that FormatKey did not change.","Do not invent alias keys for formats."],"tags":["azure-table-storage","journaling","dependency-injection","configuration","journal-format","startup"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}