Skip to content

crawl/sitemap-valid: a bare-year <lastmod> fails the whole sitemap with a parse error #687

Closed

Description

@nc9

Summary. A sitemap entry with a bare-year <lastmod>, such as <lastmod>2024</lastmod>, makes crawl/sitemap-valid report the whole file as Parse error: entry.lastmod?.trim is not a function, and none of its URLs are read. YYYY is a valid W3C Datetime, which the sitemap protocol uses for lastmod.

Cause. parseSitemap in packages/crawler/src/sitemaps.ts runs fast-xml-parser with its default value parsing, which hands a numeric text node through as a number, and the extractor calls .trim() on it. A numeric <priority> is handled; <lastmod> and <changefreq> are not.

Found while working on #662 / #670 (PR #686).

Acceptance Criteria

  • A urlset whose entries use <lastmod>2024</lastmod> parses with no errors, and each URL keeps lastmod as the string 2024.
  • One malformed entry no longer discards the other URLs in the file.
  • A test covers a bare-year lastmod next to a full datetime one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2bugsize: XS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions