{"record":{"id":"0d5a848d7a22f943","repo":"GoogleChrome/lighthouse","slug":"invalid-sitemap-url-protocol","errorCode":null,"errorMessage":"Invalid sitemap URL protocol","messagePattern":"Invalid sitemap URL protocol","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"core/audits/seo/robots-txt.js","lineNumber":84,"sourceCode":" * @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\n    if (dollarIndex !== -1 && dollarIndex !== directiveValue.length - 1) {\n      throw new Error('\"$\" should only be used at the end of the pattern');\n    }\n  }","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/core/audits/seo/robots-txt.js#L66-L102","documentation":"After successfully parsing the sitemap URL, verifyDirective checks that the URL's protocol is in SITEMAP_VALID_PROTOCOLS, which contains only 'https:', 'http:', and 'ftp:'. If the sitemap URL uses any other protocol (e.g., 'file:', 'ws:', or a custom scheme), this error fires. The error is caught internally by validateRobots and surfaced as a validation error item in audit results.","triggerScenarios":"The audited site's robots.txt contains a 'Sitemap:' directive with a valid URL that uses a protocol other than http, https, or ftp. For example: 'Sitemap: file:///path/to/sitemap.xml' or 'Sitemap: ws://example.com/sitemap'. The URL parses successfully but its .protocol property is not in the allowed set.","commonSituations":"Local development robots.txt using file:// protocol; incorrect protocol prefix (e.g., typo like 'htp://'); non-standard protocol used intentionally for internal tooling; configuration management tool inserting the wrong protocol scheme.","solutions":["Change the sitemap URL to use http or https: Sitemap: https://example.com/sitemap.xml","If using ftp, confirm it is intentional and that the FTP server serves the sitemap correctly","For local development, use a local http server and reference it by http://localhost","Verify no configuration tooling is injecting non-standard protocols"],"exampleFix":"# before (robots.txt)\nSitemap: file:///var/www/sitemap.xml\n\n# after (robots.txt)\nSitemap: https://example.com/sitemap.xml","handlingStrategy":"validation","validationCode":"// Validate sitemap URL protocol before deployment\nconst VALID_PROTOCOLS = new Set(['https:', 'http:', 'ftp:']);\nfunction validateSitemapProtocol(directiveValue) {\n  const url = new URL(directiveValue);\n  if (!VALID_PROTOCOLS.has(url.protocol)) {\n    throw new Error(`Sitemap protocol '${url.protocol}' not allowed. Use http, https, or ftp.`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use https:// (preferred) or http:// for sitemap URLs — avoid file:// and other protocols","For local development, serve robots.txt and sitemap via a local HTTP server","Validate the full sitemap URL with an online robots.txt checker before deployment"],"tags":["seo","robots-txt","validation","url","protocol"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}