{"record":{"id":"bcafa152d9306b0c","repo":"GoogleChrome/lighthouse","slug":"invalid-sitemap-url","errorCode":null,"errorMessage":"Invalid sitemap URL","messagePattern":"Invalid sitemap URL","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"core/audits/seo/robots-txt.js","lineNumber":80,"sourceCode":"const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);\n\n/**\n * @param {string} directiveName\n * @param {string} directiveValue\n * @throws will throw an exception if given directive is invalid\n */\nfunction verifyDirective(directiveName, directiveValue) {\n  if (!DIRECTIVE_SAFELIST.has(directiveName)) {\n    throw new Error('Unknown directive');\n  }\n\n  if (directiveName === DIRECTIVE_SITEMAP) {\n    let sitemapUrl;\n\n    try {\n      sitemapUrl = new URL(directiveValue);\n    } catch (e) {\n      throw new Error('Invalid sitemap URL');\n    }\n\n    if (!SITEMAP_VALID_PROTOCOLS.has(sitemapUrl.protocol)) {\n      throw new Error('Invalid sitemap URL protocol');\n    }\n  }\n\n  if (directiveName === DIRECTIVE_USER_AGENT && !directiveValue) {\n    throw new Error('No user-agent specified');\n  }\n\n  if (directiveName === DIRECTIVE_ALLOW || directiveName === DIRECTIVE_DISALLOW) {\n    if (directiveValue !== '' && directiveValue[0] !== '/' && directiveValue[0] !== '*') {\n      throw new Error('Pattern should either be empty, start with \"/\" or \"*\"');\n    }\n\n    const dollarIndex = directiveValue.indexOf('$');\n","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/core/audits/seo/robots-txt.js#L62-L98","documentation":"Within verifyDirective, when the directive is 'sitemap', Lighthouse attempts to parse the value as a URL using the URL constructor. If the constructor throws (the value is not a valid URL), this error is thrown. The error is caught internally by validateRobots and surfaced as a validation error item in audit results. A valid sitemap directive must point to a parseable URL.","triggerScenarios":"The audited site's robots.txt contains a 'Sitemap:' directive whose value cannot be parsed by the URL constructor. For example: 'Sitemap: not-a-url', 'Sitemap: /sitemap.xml' (relative URL without host in some contexts), or 'Sitemap: ftp://' (incomplete). The URL constructor will throw on any value that does not conform to URL syntax.","commonSituations":"Typo in the sitemap URL; relative path instead of absolute URL; missing protocol; copy-paste error truncating the URL; special characters that break URL parsing; trailing spaces or invisible characters in the value.","solutions":["Ensure the Sitemap directive uses a fully-qualified absolute URL: Sitemap: https://example.com/sitemap.xml","Check for typos, missing protocol, or truncated URLs in the robots.txt file","Validate the URL with an online robots.txt validator or Google Search Console","Remove invisible characters or trailing whitespace from the sitemap line"],"exampleFix":"# before (robots.txt)\nSitemap: sitemap.xml\n\n# after (robots.txt)\nSitemap: https://example.com/sitemap.xml","handlingStrategy":"validation","validationCode":"// Validate sitemap URL in robots.txt before deployment\nfunction validateSitemapUrl(directiveValue) {\n  try {\n    new URL(directiveValue);\n  } catch (e) {\n    throw new Error(`Sitemap value is not a valid URL: ${directiveValue}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use fully-qualified absolute URLs for Sitemap directives","Include the protocol: Sitemap: https://example.com/sitemap.xml","Validate the URL resolves with a browser or curl before deploying robots.txt","Use Google Search Console to submit and validate sitemaps"],"tags":["seo","robots-txt","validation","url"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}