{"record":{"id":"71a7406e8cae6a7d","repo":"dotnet/orleans","slug":"azure-table-journal-header-count-or-length-propert","errorCode":null,"errorMessage":"Azure Table journal header count or length properties are invalid.","messagePattern":"Azure Table journal header count or length properties are invalid\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Azure/Orleans.Journaling.AzureStorage/AzureTableJournalStorage.cs","lineNumber":1018,"sourceCode":"        }\n\n        return names;\n    }\n\n    private HeaderState CreateHeaderState(TableEntity entity)\n    {\n        ValidateHeaderJournalId(entity);\n        var generation = entity.GetString(GenerationPropertyName);\n        if (generation is not { Length: > 0 })\n        {\n            throw new InvalidOperationException(\"Azure Table journal header is missing its generation property.\");\n        }\n\n        var rowCount = entity.GetInt64(RowCountPropertyName);\n        var length = entity.GetInt64(LengthPropertyName);\n        if (rowCount is not >= 0 || length is not >= 0)\n        {\n            throw new InvalidOperationException(\"Azure Table journal header count or length properties are invalid.\");\n        }\n\n        // Headers written by the original provider schema did not have separate compaction counters.\n        // Conservatively treat the current generation as uncompacted until the next replacement resets them.\n        var appendRowCount = entity.GetInt64(AppendRowCountPropertyName) ?? rowCount.Value;\n        var appendLength = entity.GetInt64(AppendLengthPropertyName) ?? length.Value;\n        if (appendRowCount < 0 || appendLength < 0)\n        {\n            throw new InvalidOperationException(\"Azure Table journal header count or length properties are invalid.\");\n        }\n\n        return new HeaderState(\n            entity.ETag,\n            new HeaderProviderState(\n                NormalizeFormat(entity.GetString(FormatPropertyName)),\n                generation,\n                rowCount.Value,\n                length.Value,","sourceCodeStart":1000,"sourceCodeEnd":1036,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Journaling.AzureStorage/AzureTableJournalStorage.cs#L1000-L1036","documentation":"The header row's RowCount or Length property is missing or negative. CreateHeaderState (AzureTableJournalStorage.cs:1014-1015) reads them via GetInt64 (which returns null when absent) and the guard `rowCount is not >= 0 || length is not >= 0` fails for both null and negative values. These counters bound data-row iteration, so invalid values make the journal unreadable.","triggerScenarios":"Reading the header when RowCount and/or Length is absent or < 0; thrown at AzureTableJournalStorage.cs:1018.","commonSituations":"External edit removed or negated RowCount/Length; a partial header write by a non-provider tool; schema drift where a field was renamed; legacy header that predates one of these required columns being treated as required.","solutions":["Delete or repair the $header row so RowCount and Length are present and non-negative.","Confirm no tooling mutates the $header entity outside the provider.","Trigger a journal Replace to publish a fresh, fully-populated header."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { /* read header */ }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"count or length properties are invalid\"))\n{\n    // Repair or reset the $header row.\n}","preventionTips":["Keep header counters under provider control only.","Avoid partial header writes from external tools.","Trigger a Replace to repopulate counters."],"tags":["azure-table","data-corruption","journal","header"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}