Skip to content

fix(utils): keep urls from the other sitemaps when one sitemap is malformed - #4249

Open
jayhemnani9910 wants to merge 1 commit into
apify:masterfrom
jayhemnani9910:fix/sitemap-malformed-child
Open

jayhemnani9910 wants to merge 1 commit into
apify:masterfrom
jayhemnani9910:fix/sitemap-malformed-child

Conversation

@jayhemnani9910

Copy link
Copy Markdown

Sitemap.load() returns an empty list when any one of the sitemaps it reads fails to parse. That includes a single child of a sitemap index. One unescaped & is enough:

// robots.txt lists sitemap-products.xml (valid) and sitemap-blog.xml (has a `<loc>` with `?tag=a&b`)
const robots = await RobotsTxtFile.find('https://example.com/');
await robots.parseUrlsFromSitemaps(); // [], the product URLs are lost too

parseSitemap checks for parser errors right after it sets up the pipeline, but the pipeline reports them later. The error is thrown from the for await over the parsed items instead, escapes parseSitemap, and Sitemap.#parse catches it and discards every URL it has collected. RobotsTxtFile.parseUrlsFromSitemaps() passes no logger, so there it fails silently.

Now an error while reading one sitemap logs Malformed sitemap content: <url> and the parser moves on to the next sitemap. Raw string sources already log the error in their pipeline callback, so they are not logged twice. SitemapRequestLoader already read each sitemap on its own; for a malformed one it now gets this warning from parseSitemap instead of its own Error loading sitemap contents log.

Reproduced on 4.0.0-rc.1 and 3.18.2.

Copilot AI balanced review requested due to automatic review settings October 10, 2026 07:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Oct 10, 2026

This branch has not been deployed

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

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants