dotnet/orleans · error · ArgumentException

Journal metadata property names must not contain null charac

Error message

Journal metadata property names must not contain null characters.

What it means

A caller-supplied journal metadata property name contains a NUL (\0) character. ValidateCallerMetadataPropertyName (AzureTableJournalStorage.cs:1167) rejects embedded NULs because they break string handling in Azure Table property names and downstream serialization. The argument blamed is `key`.

Source

Thrown at src/Azure/Orleans.Journaling.AzureStorage/AzureTableJournalStorage.cs:1172

                changed = true;
            }
        }

        return changed;
    }

    private static void ValidateCallerMetadataProperty(string key, string value)
    {
        ValidateCallerMetadataPropertyName(key);
        ArgumentNullException.ThrowIfNull(value);
    }

    private static void ValidateCallerMetadataPropertyName(string key)
    {
        ArgumentException.ThrowIfNullOrWhiteSpace(key);
        if (key.IndexOf('\0') >= 0)
        {
            throw new ArgumentException("Journal metadata property names must not contain null characters.", nameof(key));
        }

        if (key.StartsWith("$", StringComparison.Ordinal))
        {
            throw new ArgumentException($"Journal metadata property '{key}' is provider-owned.", nameof(key));
        }
    }

    private static ETag ToAzureETag(string eTag)
    {
        ArgumentException.ThrowIfNullOrWhiteSpace(eTag);
        return new ETag(eTag);
    }

    private static bool IsEntityAlreadyExists(RequestFailedException exception)
        => exception.Status == 409
            && (string.Equals(exception.ErrorCode, "EntityAlreadyExists", StringComparison.Ordinal)
                || exception.Message.Contains("already exists", StringComparison.OrdinalIgnoreCase));

View on GitHub (pinned to fca799fa70)

Solutions

  1. Sanitize keys before the call: strip or reject NUL characters.
  2. Validate keys come from a controlled vocabulary rather than raw external input.
  3. Add a unit test asserting metadata keys are printable.

Example fix

// before
storage.SetMetadata(new() { [badKey] = "v" }); // badKey contains '\0'

// after
var safeKey = badKey.Replace("\0", string.Empty);
if (string.IsNullOrWhiteSpace(safeKey)) throw new ArgumentException("Empty key");
storage.SetMetadata(new() { [safeKey] = "v" });
Defensive patterns

Strategy: validation

Validate before calling

foreach (var k in metadata.Keys)
    if (k.IndexOf('\0') >= 0) throw new ArgumentException($"Key '{k}' contains a NUL character");

Type guard

static bool HasNoNul(string key) => key.IndexOf('\0') < 0;

Prevention

When it happens

Trigger: Calling a metadata set/update API with a dictionary key or remove-set entry containing '\0'; thrown at AzureTableJournalStorage.cs:1172.

Common situations: A key was read from a binary/encoded source without sanitizing; concatenated buffers introduced a NUL; user input was not validated before becoming a metadata key.

Related errors


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