Skip to content

crawl/sitemap-valid: gzip child sitemaps reported as "Unknown sitemap format" #662

Closed

Description

@deniskern

Summary. squirrel 0.0.108 reports Unknown sitemap format for gzip-compressed child sitemap files served as Content-Type: application/gzip without Content-Encoding. The same XML in an uncompressed child sitemap passes.

Data. This affects the sitemap layouts observed on or24.de and delife.de: all 15 child sitemaps on or24.de and the single child sitemap on delife.de were flagged.
The inspected or24.de child sitemap is served as application/gzip and decompresses to approximately 3 MB of well-formed XML (xmllint --noout exit 0). This check establishes XML well-formedness, not sitemap-schema validity.

Repro. Save the following as sitemap-repro.cjs. It serves a gzip fixture on port 8766 and an uncompressed control on port 8767. Both use the same sitemap XML, with URLs adjusted to their respective ports. The gzip response uses Content-Type: application/gzip without Content-Encoding.

const http = require('node:http');
const { gzipSync } = require('node:zlib');

for (const [port, compressed] of [[8766, true], [8767, false]]) {
  const base = `http://127.0.0.1:${port}`;
  const childPath = compressed ? '/child.xml.gz' : '/child.xml';
  const namespace = 'http://www.sitemaps.org/schemas/sitemap/0.9';
  const child = `<urlset xmlns="${namespace}"><url><loc>${base}/</loc></url></urlset>`;
  const routes = {
    '/': ['text/html; charset=utf-8', '<!doctype html><html lang="en"><head><title>Sitemap fixture</title></head><body>Fixture</body></html>'],
    '/robots.txt': ['text/plain; charset=utf-8', `Sitemap: ${base}/sitemap.xml\n`],
    '/sitemap.xml': ['application/xml; charset=utf-8', `<sitemapindex xmlns="${namespace}"><sitemap><loc>${base}${childPath}</loc></sitemap></sitemapindex>`],
    [childPath]: compressed
      ? ['application/gzip', gzipSync(Buffer.from(child))]
      : ['application/xml; charset=utf-8', child],
  };
  http.createServer((req, res) => {
    const route = routes[req.url];
    if (!route) {
      res.writeHead(404);
      return res.end();
    }
    res.writeHead(200, { 'Content-Type': route[0] });
    res.end(route[1]);
  }).listen(port, '127.0.0.1');
}
node sitemap-repro.cjs

In another terminal:

squirrel --version
squirrel audit http://127.0.0.1:8766/ --http --refresh -m 2 -f json -o gzip.json --rule-include crawl/sitemap-valid
squirrel audit http://127.0.0.1:8767/ --http --refresh -m 2 -f json -o plain.json --rule-include crawl/sitemap-valid

Actual (spark-onedot, 2026-10-11, squirrel 0.0.108): gzip → crawl/sitemap-valid, check sitemap-syntax, status fail, message 1 error(s) in 1 sitemap(s); child http://127.0.0.1:8766/child.xml.gz has Unknown sitemap format. Uncompressed control → issues: []; 1 URL discovered in the sitemap. Both audits crawled 1 page.

Expected: accept gzip-compressed child sitemap files permitted by the sitemap protocol. After HTTP content decoding, decompress a remaining gzip file before parsing its XML. The fixture must not produce Unknown sitemap format. This reproduction covers Content-Type: application/gzip without Content-Encoding; it does not establish a failure of HTTP gzip content decoding.

The sitemap protocol explicitly permits gzip files and shows .xml.gz children in a sitemap index.

Acceptance Criteria

  • The gzip fixture from the repro (application/gzip, no Content-Encoding, .xml.gz child of a sitemap index) no longer produces Unknown sitemap format, and its URLs are discovered like the uncompressed control.
  • A body that starts with the gzip magic bytes is decompressed once, then parsed as XML; a sitemap served with Content-Encoding: gzip still works.
  • Decompression is bounded: output over the 50 MB uncompressed sitemap limit is refused with a clear error, so a gzip bomb cannot exhaust memory.
  • A corrupt gzip body reports a specific error (not Unknown sitemap format).
  • Tests cover gzip child, plain child, corrupt gzip and oversize.

Activity

  1. added
    bug
    P2
    size: S
    on Oct 11, 2026
  2. nc9 commented on Oct 11, 2026

    @nc9
    Contributor

    Thanks Denis. Confirmed the source of the message: Unknown sitemap format comes from the sitemap parser in packages/crawler/src/sitemaps.ts, so this is a crawler fix, not a rule change (the rule just reports what the parser returns). Triaged as a bug (P2: it makes valid sitemap indexes read as broken), size S. I added acceptance criteria, including a bound on decompressed size so a gzip bomb cannot exhaust memory, and a distinct error for a corrupt gzip body.

  3. nc9 commented on Oct 11, 2026

    @nc9
    Contributor

    Reproduced on 0.0.108 with the repro script (ports changed). Gzip child: crawl/sitemap-valid, check sitemap-syntax, status fail, 1 error(s) in 1 sitemap(s), item http://127.0.0.1:8807/child.xml.gz labelled Unknown sitemap format. The uncompressed control passes.

    origin/main still has this: packages/crawler/src/sitemaps.ts reads every sitemap body with response.text() in fetchSitemap and hands it to parseSitemap with no check for gzip magic bytes, so the compressed bytes reach the XML parser as text.

  4. nc9 commented on Oct 12, 2026

    @nc9
    Contributor

    Fixed in # and merged to main. Every acceptance criterion is met per the PR description, with before and after evidence from the CLI on local fixtures, tests that fail on the old code, and review comments triaged. Criteria ticked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2bugsize: S

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions