Root CauseWhat broke, why, and the fix.

An empty generator group left 2,482 pages out of a sitemap for 22 days

· debugging, sitemaps, build validation
ⓘ Operated by TechAthletes. Every post here is a bug we hit in our own work — symptom, root cause, fix. Nothing is sponsored and we are not paid to mention any tool.

The glossary had a group but no URLs

On September 27, a sitemap investigation found that an entire glossary was missing from the generated sitemaps. The glossary had been published on September 5: 1,241 terms in two languages, making 2,482 pages. For 22 days, none of those pages appeared in a sitemap. The missing pages represented 69% of the recorded site total of 3,610.

The generator, sitemap.mjs, divided URLs into groups and wrote a separate sitemap for each populated group. There was already a glossary entry in that grouping logic. Looking at the available categories, the generator appeared to support glossary pages.

The relevant code showed both the category and the behavior that concealed its missing contents:

const groups = {
  pages:    urls.filter(...),
  glossary: urls.filter((u) => /\/glossary\//.test(u.loc)),   // ← 枠は在る
  articles: urls.filter(...),
  ...
};
for (const [name, list] of Object.entries(groups)) {
  if (!list.length) continue;          // ← 空の塊は黙って飛ばす
  await fs.writeFile(`sitemap-${name}.xml`, render(list));
}

The glossary filter could select matching URLs from urls. It could not supply URLs that were absent from that array. There was no code anywhere that pushed the glossary URLs into urls, so the glossary group was always empty.

The loop then did exactly what its empty-list condition instructed: it skipped the group. The generator never created sitemap-glossary.xml, and that file returned 404. The category existed in the code, but the pages never reached it.

Successful checks made an incomplete result look healthy

The sitemap protocol only specifies the structure of the files that exist — it has no mechanism for declaring which URLs should have been included, so a valid sitemap index with a missing child sitemap is not something the format itself can flag (Source: sitemaps.org: Sitemaps XML format).

The omission remained unnoticed because the generated output did not look broken. The sitemap index, sitemap.xml, was valid XML with the correct structure for an index. The generated child sitemaps returned 200, were valid, and contained URLs that actually existed.

Those observations were accurate. They simply described the files and entries that the generator had produced. They did not establish whether all the pages that should have appeared were present.

The listed URL count was 1,126. That count could increase as articles were written, so growth made the sitemap appear healthy. But a growing count did not answer whether the glossary had contributed anything to it. Existing categories could continue adding entries while another category remained absent.

Search Console also showed the following on the relevant row:

errors: 0

That result did not expose the missing glossary pages. Neither did valid XML, successful responses from generated child sitemaps, or checks that listed URLs existed. The absent file was outside the set of generated child sitemaps whose successful responses made the output look sound.

This was the distinction that mattered: checking an existing entry can establish that the entry is valid. It cannot establish that a different, expected entry has not been omitted. Without a separate collection of published pages to compare against, the inspection had no way to identify what was missing.

The fetch symptom pointed the investigation toward the wrong question

The investigation initially followed a different symptom. Search Console displayed:

Couldn't fetch

That wording led to suspicion of a retrieval-path problem. The possibilities examined included robots.txt, size, redirects, and the service worker. These were the initial directions of investigation, not established causes.

Actual measurements showed that fetching succeeded. The root cause recorded in the investigation was the missing coverage: the glossary pages were not listed.

The record does not establish why Search Console displayed that message. It does establish that the message did not identify the generator defect. Following the wording alone kept attention on whether the sitemap could be retrieved, while the missing input required a different question: which published pages had reached the sitemap?

The causal chain inside the generator was specific. Glossary URLs were never added to the source array. Filtering that array therefore produced an empty glossary list. The empty-list condition skipped writing the file. The expected glossary sitemap consequently did not exist.

Nothing in that chain required malformed XML or a bad URL inside an existing sitemap. The defect happened before those checks could encounter a glossary entry. By the time output validation began, the missing category had already disappeared from the generated result.

The fix made every published page accountable

The added safeguard compared the sitemap against published content. It enumerated published index.html files and checked whether each page appeared either in the sitemap or in an exclusion list. If even one page appeared in neither place, the build stopped.

This gave the check an independent reference set. Instead of asking only whether the output was valid, it asked whether published pages had been accounted for.

The exclusion list also required a reason. The recorded exclusions covered personal pages available after login, landing pages after payment, and tag listings excluded by policy because their content was considered thin. These were explicit decisions about what should stay out of the sitemap.

The rule was that a page without an exclusion reason should be included. That made an intentional omission distinguishable from a forgotten input path. A newly added page category could no longer disappear merely because its URLs had never been supplied to the generator: published pages missing from both the sitemap and the exclusions would fail the build.

A negative test checked the safeguard by passing no entries. It detected 3,606 pages and raised an exception. That result demonstrated the failure behavior the new check was meant to provide. An empty supplied set did not pass simply because there was no malformed output to reject.

The safeguard addressed the omission at the level where it could be observed: the relationship between published pages and sitemap coverage. It did not depend on the glossary group having a particular name or on someone remembering to inspect its generated file.

Check completeness against the pages you actually publish

The lesson from this incident is to keep validity and completeness as separate checks. Validity asks whether the generated files and their contents meet the expected format. Completeness asks whether everything that should be represented has been included.

For a sitemap generator, the recorded approach provides a concrete check to reproduce: enumerate published pages, compare them with sitemap entries, and require an explicit reason for each exclusion. A published page that belongs to neither set should stop the build.

The empty-list branch deserves its own review. Wherever a generator uses if (!list.length) continue;, ask whether an empty group is a legitimate result for that category. In this incident, the code treated an empty glossary group as something to skip even though glossary pages had already been published.

The same inspection applies to category-based feeds, generated indexes, Open Graph output, and notifications—the other generator shapes identified in the record. A group, switch branch, or routing entry can exist without receiving the items it is supposed to process. Its presence in the code is not evidence that its inputs are connected.

Finally, test the coverage check with missing input. The recorded negative test made the expected response observable: omissions produced an exception. That is the useful property to verify in your own environment. A generator should not be considered complete solely because every artifact it happened to produce is valid.

Root Cause is written while shipping small software products — you can see them at TechAthletes.

All posts →

Get new posts by email

We email you only when a new post goes up here. You can unsubscribe at any time.

Privacy policy