{"record":{"id":"da7211fdc8bcbe7b","repo":"dotnet/orleans","slug":"the-journal-id-must-not-be-the-default-value-da7211","errorCode":null,"errorMessage":"The journal id must not be the default value.","messagePattern":"The journal id must not be the default value\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Azure/Orleans.Journaling.AzureStorage/AzureBlobJournalStorageProvider.cs","lineNumber":52,"sourceCode":"            new AzureBlobJournalStorage.OptionsBlobClientProvider(_containerFactory, _options),\n            instruments ?? AzureBlobJournalStorageInstruments.CreateForDirectConstruction(),\n            mimeType: journalFormat.MimeType,\n            journalFormatKey: journalFormatKey);\n    }\n\n    private async Task Initialize(CancellationToken cancellationToken)\n    {\n        var client = await _options.CreateClient!(cancellationToken);\n        _defaultContainer = client.GetBlobContainerClient(_options.ContainerName);\n        await _defaultContainer.CreateIfNotExistsAsync(cancellationToken: cancellationToken).ConfigureAwait(false);\n        await _containerFactory.InitializeAsync(client, cancellationToken).ConfigureAwait(false);\n    }\n\n    public IJournalStorage CreateStorage(JournalId journalId)\n    {\n        if (journalId.IsDefault)\n        {\n            throw new ArgumentException(\"The journal id must not be the default value.\", nameof(journalId));\n        }\n\n        return new AzureBlobJournalStorage(_shared, journalId);\n    }\n\n    public async IAsyncEnumerable<JournalId> ListAsync(\n        JournalId prefix = default,\n        [EnumeratorCancellation] CancellationToken cancellationToken = default)\n    {\n        var container = GetDefaultContainerClient();\n        var blobPrefix = prefix.IsDefault ? null : prefix.Value;\n        var journalIds = new List<JournalId>();\n        await foreach (var item in container.GetBlobsAsync(\n            traits: BlobTraits.None,\n            states: BlobStates.None,\n            prefix: blobPrefix,\n            cancellationToken: cancellationToken))\n        {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Journaling.AzureStorage/AzureBlobJournalStorageProvider.cs#L34-L70","documentation":"Thrown by AzureBlobJournalStorageProvider.CreateStorage when the JournalId is default. Each journal maps to a distinct Azure Blob; a default journal id has no value and cannot be addressed. CreateStorage is the entry point used by the journaled-state manager to obtain a per-journal storage handle.","triggerScenarios":"Calling provider.CreateStorage(default(JournalId)) or with a JournalId that was never assigned a value. The check is the first statement in the method.","commonSituations":"Default-structuring a JournalId field in a grain; passing an uninitialized id obtained from a deserialized object; a bug in grain activation that does not set the journal id before requesting storage.","solutions":["Always construct the JournalId from a non-empty string before calling CreateStorage.","Initialize the journal id during grain activation, before requesting storage.","Validate journalId.IsDefault at the call site and fail early with a domain-specific error."],"exampleFix":"// before\nvar storage = provider.CreateStorage(default(JournalId));\n\n// after\nvar storage = provider.CreateStorage(new JournalId(this.GetGrainId().ToString()));","handlingStrategy":"type-guard","validationCode":"if (journalId.IsDefault) throw new InvalidOperationException(\"JournalId not initialized before CreateStorage.\");\nvar storage = provider.CreateStorage(journalId);","typeGuard":"static bool IsUsableJournalId(JournalId id) => !id.IsDefault;","tryCatchPattern":null,"preventionTips":["Construct JournalId at grain activation from a deterministic key.","Guard CreateStorage calls with journalId.IsDefault.","Avoid default(JournalId) field initializers."],"tags":["azure-blob-storage","journal-id","validation","argument"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}