From 968fe21080af5150ee7611f04c572864cc7a8384 Mon Sep 17 00:00:00 2001 From: Ali Date: Tue, 14 Apr 2026 01:27:05 +0500 Subject: [PATCH] restapi: include inactiveShards in the homepage total count The HTML homepage served at / displays the log's total entry count but only reads j.treeSize from the /api/v1/log/ response, ignoring j.inactiveShards. After a shard rotation the total entry count is the sum of the active tree plus every inactive shard, so the page under- reports by the size of all previous shards. Sum the inactiveShards tree sizes into the displayed count, guarding against a missing or non-array inactiveShards field with a defensive Array.isArray check and Number() coercion. Fixes #2281 Signed-off-by: Ali --- pkg/generated/restapi/rekorHomePage.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/generated/restapi/rekorHomePage.html b/pkg/generated/restapi/rekorHomePage.html index 95566acb0..e9fb4af02 100644 --- a/pkg/generated/restapi/rekorHomePage.html +++ b/pkg/generated/restapi/rekorHomePage.html @@ -34,7 +34,14 @@

function update() { fetch(url, {headers: {'Accept': 'application/json'}}).then((resp) => { resp.json().then((j) => { - let count = j.treeSize; + // Total across the active shard plus any inactive shards; otherwise + // the page under-reports after a shard rotation. + let count = Number(j.treeSize) || 0; + if (Array.isArray(j.inactiveShards)) { + for (const shard of j.inactiveShards) { + count += Number(shard.treeSize) || 0; + } + } document.getElementById('count').innerText = count; }).catch(console.error); }).catch(console.error);