dotnet/orleans · error · ArgumentException

The journal id must not be the default value.

Error message

The journal id must not be the default value.

What it means

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.

Source

Thrown at src/Azure/Orleans.Journaling.AzureStorage/AzureTableJournalStorageOptions.cs:106

    /// <summary>
    /// Gets or sets the upper bound on the per-attempt backoff used by metadata-only conflict
    /// retries. The exponential schedule starts at <see cref="MetadataOnlyConflictInitialBackoff"/>
    /// and never exceeds this value. Defaults to 200 ms.
    /// </summary>
    public TimeSpan MetadataOnlyConflictMaxBackoff { get; set; } = DEFAULT_METADATA_ONLY_CONFLICT_MAX_BACKOFF;
    public static readonly TimeSpan DEFAULT_METADATA_ONLY_CONFLICT_MAX_BACKOFF = TimeSpan.FromMilliseconds(200);

    /// <summary>
    /// The optional delegate used to create a <see cref="TableServiceClient"/> instance.
    /// </summary>
    internal Func<CancellationToken, Task<TableServiceClient>>? CreateClient { get; private set; }

    internal string GetPartitionKeyForJournal(JournalId journalId)
    {
        if (journalId.IsDefault)
        {
            throw new ArgumentException("The journal id must not be the default value.", nameof(journalId));
        }

        var mapper = GetPartitionKey ?? throw new ArgumentNullException(nameof(GetPartitionKey));
        var partitionKey = mapper(journalId);
        ArgumentException.ThrowIfNullOrWhiteSpace(partitionKey);
        ValidatePartitionKey(partitionKey, nameof(partitionKey));
        return partitionKey;
    }

    internal static string GetDefaultPartitionKey(JournalId journalId)
    {
        if (journalId.IsDefault)
        {
            throw new ArgumentException("The journal id must not be the default value.", nameof(journalId));
        }

        // Percent-encoding escapes every character disallowed in partition keys ('/', '\', '#', '?',
        // control characters) and is reversible.

View on GitHub (pinned to fca799fa70)

Solutions

  1. Ensure the JournalId is assigned a non-default value before it reaches journal storage (e.g., from the grain activation / journal registry).
  2. Guard at the call site: if (journalId.IsDefault) throw early with context.
  3. Check that the id source (key, address) is wired up and not returning default.

Example fix

// before
var pk = options.GetPartitionKeyForJournal(default(JournalId));

// after
if (journalId.IsDefault) throw new InvalidOperationException("JournalId not assigned");
var pk = options.GetPartitionKeyForJournal(journalId);
Defensive patterns

Strategy: validation

Validate before calling

if (journalId.IsDefault) throw new InvalidOperationException("JournalId must be assigned before partition-key derivation");
var partitionKey = options.GetPartitionKeyForJournal(journalId);

Type guard

static bool IsJournalIdAssigned(JournalId id) => !id.IsDefault;

Prevention

When it happens

Trigger: Calling GetPartitionKeyForJournal (or any path that derives a partition key) with a JournalId whose IsDefault is true; thrown at AzureTableJournalStorageOptions.cs:106.

Common situations: 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.

Related errors


AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13). Data as JSON: /api/errors/76c3461943674fcf. Report an issue: GitHub.