{"record":{"id":"76c3461943674fcf","repo":"dotnet/orleans","slug":"the-journal-id-must-not-be-the-default-value-76c346","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/AzureTableJournalStorageOptions.cs","lineNumber":106,"sourceCode":"\n    /// <summary>\n    /// Gets or sets the upper bound on the per-attempt backoff used by metadata-only conflict\n    /// retries. The exponential schedule starts at <see cref=\"MetadataOnlyConflictInitialBackoff\"/>\n    /// and never exceeds this value. Defaults to 200 ms.\n    /// </summary>\n    public TimeSpan MetadataOnlyConflictMaxBackoff { get; set; } = DEFAULT_METADATA_ONLY_CONFLICT_MAX_BACKOFF;\n    public static readonly TimeSpan DEFAULT_METADATA_ONLY_CONFLICT_MAX_BACKOFF = TimeSpan.FromMilliseconds(200);\n\n    /// <summary>\n    /// The optional delegate used to create a <see cref=\"TableServiceClient\"/> instance.\n    /// </summary>\n    internal Func<CancellationToken, Task<TableServiceClient>>? CreateClient { get; private set; }\n\n    internal string GetPartitionKeyForJournal(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        var mapper = GetPartitionKey ?? throw new ArgumentNullException(nameof(GetPartitionKey));\n        var partitionKey = mapper(journalId);\n        ArgumentException.ThrowIfNullOrWhiteSpace(partitionKey);\n        ValidatePartitionKey(partitionKey, nameof(partitionKey));\n        return partitionKey;\n    }\n\n    internal static string GetDefaultPartitionKey(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        // Percent-encoding escapes every character disallowed in partition keys ('/', '\\', '#', '?',\n        // control characters) and is reversible.","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Journaling.AzureStorage/AzureTableJournalStorageOptions.cs#L88-L124","documentation":"AzureTableJournalStorageOptions.GetPartitionKeyForJournal (AzureTableJournalStorageOptions.cs:102) was called with a default JournalId (JournalId.IsDefault is true). A default journal id has no identity, so it cannot be mapped to a stable partition key; the provider rejects it before computing a key. This is a programmer error: the journal was not assigned an id before use.","triggerScenarios":"Calling GetPartitionKeyForJournal (or any path that derives a partition key) with a JournalId whose IsDefault is true; thrown at AzureTableJournalStorageOptions.cs:106.","commonSituations":"A JournalId struct was left uninitialized; a code path created a JournalId without assigning its Value; a default-constructed grain attempted journaling before its id was set.","solutions":["Ensure the JournalId is assigned a non-default value before it reaches journal storage (e.g., from the grain activation / journal registry).","Guard at the call site: if (journalId.IsDefault) throw early with context.","Check that the id source (key, address) is wired up and not returning default."],"exampleFix":"// before\nvar pk = options.GetPartitionKeyForJournal(default(JournalId));\n\n// after\nif (journalId.IsDefault) throw new InvalidOperationException(\"JournalId not assigned\");\nvar pk = options.GetPartitionKeyForJournal(journalId);","handlingStrategy":"validation","validationCode":"if (journalId.IsDefault) throw new InvalidOperationException(\"JournalId must be assigned before partition-key derivation\");\nvar partitionKey = options.GetPartitionKeyForJournal(journalId);","typeGuard":"static bool IsJournalIdAssigned(JournalId id) => !id.IsDefault;","tryCatchPattern":null,"preventionTips":["Assign the JournalId from the grain/journal registry before storage use.","Guard at the call site when ids come from external sources.","Unit-test that id assignment happens before first read/write."],"tags":["journal-id","validation","api-usage"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}