{"record":{"id":"ba001010dfb22198","repo":"dotnet/orleans","slug":"journal-format-key-journalformatkey-requires-k","errorCode":null,"errorMessage":"Journal format key '{journalFormatKey}' requires keyed service '{typeof(IJournalFormat).FullName}', but none was registered.","messagePattern":"Journal format key '(.+?)' requires keyed service '(.+?)', but none was registered\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"src/Azure/Orleans.Journaling.AzureStorage/AzureBlobJournalStorageProvider.cs","lineNumber":126,"sourceCode":"    {\n        try\n        {\n            journalId = new JournalId(value);\n            return true;\n        }\n        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.\");","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Journaling.AzureStorage/AzureBlobJournalStorageProvider.cs#L108-L144","documentation":"Thrown by AzureBlobJournalStorageProvider during construction when the configured journal format key resolves to no registered keyed IJournalFormat service. The provider looks up the format by key (from JournaledStateManagerOptions.JournalFormatKey) via GetKeyedService; a missing registration means no format plugin can serialize/deserialize journal data, so startup fails.","triggerScenarios":"Setting JournaledStateManagerOptions.JournalFormatKey to a value (e.g. 'json') but forgetting to register the corresponding keyed IJournalFormat service with services.AddKeyedSingleton<IJournalFormat>(\"json\", ...). The provider constructor runs during DI activation.","commonSituations":"Upgrading to a version that renamed the default format key; adding a custom format without registering it; mispelling the format key between configuration and registration; removing a format package from project references.","solutions":["Register the IJournalFormat implementation under the exact key specified by JournaledStateManagerOptions.JournalFormatKey, e.g. services.AddKeyedSingleton<IJournalFormat>(\"json\", (sp, _) => new JsonJournalFormat()).","Ensure the format key in configuration matches the key used at registration (case-sensitive, ordinal).","Check that the package providing your IJournalFormat implementation is referenced."],"exampleFix":"// before\nmanagerOptions.JournalFormatKey = \"json\";\n// missing: no IJournalFormat registration for \"json\"\n\n// after\nmanagerOptions.JournalFormatKey = \"json\";\nservices.AddKeyedSingleton<IJournalFormat>(\"json\", (sp, _) => new JsonJournalFormat());","handlingStrategy":"validation","validationCode":"// Validate at startup that the keyed service exists:\nusing var scope = services.BuildServiceProvider().CreateScope();\nvar fmt = scope.ServiceProvider.GetKeyedService<IJournalFormat>(managerOptions.JournalFormatKey);\nif (fmt is null) throw new InvalidOperationException($\"No IJournalFormat registered for '{managerOptions.JournalFormatKey}'.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register IJournalFormat keyed services in the same composition root that sets JournalFormatKey.","Add a startup health check that resolves the keyed service.","Pin the format key in a shared constant to avoid drift between config and registration."],"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"}