dotnet/orleans · error · InvalidOperationException

Azure Table journal header metadata property is invalid.

Error message

Azure Table journal header metadata property is invalid.

What it means

The header row's Metadata property is not valid JSON for a Dictionary<string,string>. DeserializeCallerMetadata (AzureTableJournalStorage.cs:1069) parses the Metadata column with System.Text.Json; on JsonException it wraps the error in this InvalidOperationException. The provider always writes well-formed JSON (SerializeCallerMetadata at line 1066), so malformed JSON indicates corruption or an incompatible writer.

Source

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

    private static string SerializeCallerMetadata(IReadOnlyDictionary<string, string>? metadata)
        => metadata is { Count: > 0 } ? JsonSerializer.Serialize(metadata) : "{}";

    private static Dictionary<string, string> DeserializeCallerMetadata(string? json)
    {
        if (json is not { Length: > 0 })
        {
            return new Dictionary<string, string>(StringComparer.Ordinal);
        }

        Dictionary<string, string>? parsed;
        try
        {
            parsed = JsonSerializer.Deserialize<Dictionary<string, string>>(json);
        }
        catch (JsonException exception)
        {
            throw new InvalidOperationException("Azure Table journal header metadata property is invalid.", exception);
        }

        var result = new Dictionary<string, string>(StringComparer.Ordinal);
        if (parsed is not null)
        {
            foreach (var (key, value) in parsed)
            {
                result[key] = value;
            }
        }

        return result;
    }

    private static Dictionary<string, string> CopyAndValidateCallerMetadata(IReadOnlyDictionary<string, string>? metadata)
    {
        var result = new Dictionary<string, string>(StringComparer.Ordinal);
        if (metadata is null)

View on GitHub (pinned to fca799fa70)

Solutions

  1. Reset the Metadata column to "{}" (the empty-dictionary serialization) or delete the header so it is regenerated.
  2. Ensure only the provider writes the Metadata property.
  3. If migrating metadata, serialize with JsonSerializer.Serialize(Dictionary<string,string>) before writing.
Defensive patterns

Strategy: try-catch

Try / catch

try { /* read header */ }
catch (InvalidOperationException ex) when (ex.InnerException is System.Text.Json.JsonException)
{
    // Metadata column is corrupt; reset to "{}" or Replace the header.
}

Prevention

When it happens

Trigger: entity.GetString(MetadataPropertyName) returns a non-JSON or wrong-shaped string; JsonSerializer.Deserialize<Dictionary<string,string>> throws JsonException; wrapped and rethrown at AzureTableJournalStorage.cs:1083.

Common situations: An external editor typed a free-text value into the Metadata column; a non-provider writer stored a JSON object with non-string values; truncation cut the JSON mid-payload; an older schema stored a different Metadata format.

Related errors


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