GoogleChrome/lighthouse · warning · Error

Syntax not understood

Error message

Syntax not understood

What it means

Thrown by parseLine() when a non-empty, non-comment line in robots.txt contains no colon (':') character. Every valid robots.txt directive uses the form 'Directive: value', so a line without a colon cannot be parsed into a directive/value pair. The error indicates genuinely unparseable syntax.

Source

Thrown at core/audits/seo/robots-txt.js:126

 * @return {{directive: string, value: string}|null}
 */
function parseLine(line) {
  const hashIndex = line.indexOf('#');

  if (hashIndex !== -1) {
    line = line.substr(0, hashIndex);
  }

  line = line.trim();

  if (line.length === 0) {
    return null;
  }

  const colonIndex = line.indexOf(':');

  if (colonIndex === -1) {
    throw new Error('Syntax not understood');
  }

  const directiveName = line.slice(0, colonIndex).trim().toLowerCase();
  const directiveValue = line.slice(colonIndex + 1).trim();

  verifyDirective(directiveName, directiveValue);

  return {
    directive: directiveName,
    value: directiveValue,
  };
}

/**
 * @param {string} content
 * @return {Array<{index: string, line: string, message: string}>}
 */
function validateRobots(content) {

View on GitHub (pinned to 9515cd4e58)

Solutions

  1. Prefix the line with '#' to make it a comment, e.g. '# This section blocks private pages'
  2. Rewrite the line in valid directive syntax, e.g. 'Disallow: /path'
  3. Remove the line if it was not meant to be a directive

Example fix

// before
This blocks the admin section

// after
# This blocks the admin section
Disallow: /admin
Defensive patterns

Strategy: validation

Validate before calling

// Validate that every non-comment, non-empty line has a colon
function validateLineSyntax(content) {
  const lines = content.split(/\r\n|\r|\n/);
  const errors = [];
  lines.forEach((line, idx) => {
    const noComment = line.split('#')[0].trim();
    if (noComment.length > 0 && !noComment.includes(':')) {
      errors.push(`Line ${idx + 1}: No colon found — syntax not understood`);
    }
  });
  return errors;
}

Try / catch

try {
  parseLine(line);
} catch (e) {
  // e.message === 'Syntax not understood'
  robotsErrors.push({ line, message: e.message });
}

Prevention

When it happens

Trigger: A robots.txt line like 'BlockEverything' (no directive syntax), 'Some free text note', or a line with only spaces/words but no colon. Also triggered by malformed lines where the colon was accidentally replaced or deleted.

Common situations: Adding human-readable notes or labels in robots.txt without using '#' comment syntax. Corrupted file from a deploy or encoding issue. Pasting documentation text directly into the file. A misconfigured server-side template that strips or replaces colons.

Related errors


AI-assisted analysis of GoogleChrome/lighthouse@9515cd4e58 (2026-08-13). Data as JSON: /api/errors/5cb175d9eaf60e58. Report an issue: GitHub.