microsoft/playwright-mcp · error · Error

Markers for generated section not found in README

Error message

Markers for generated section not found in README

What it means

update-readme.js regenerates README sections by locating HTML comment markers (`<!--- ... generated by ... -->` and `<!--- End of ... generated section -->`) inside README.md and splicing new content between them. `updateSection` throws this error when either the start or end marker string cannot be found via `indexOf`, meaning the README no longer contains intact, well-formed markers. It exists as a fail-fast guard so the script never silently appends duplicate sections or clobbers the wrong part of the doc.

Source

Thrown at update-readme.js:109

    lines.push(`  - Parameters: None`);
  }
  lines.push(`  - Read-only: **${tool.type === 'readOnly'}**`);
  lines.push('');
  return lines;
}

/**
 * @param {string} content
 * @param {string} startMarker
 * @param {string} endMarker
 * @param {string[]} generatedLines
 * @returns {Promise<string>}
 */
async function updateSection(content, startMarker, endMarker, generatedLines) {
  const startMarkerIndex = content.indexOf(startMarker);
  const endMarkerIndex = content.indexOf(endMarker);
  if (startMarkerIndex === -1 || endMarkerIndex === -1)
    throw new Error('Markers for generated section not found in README');

  return [
    content.slice(0, startMarkerIndex + startMarker.length),
    '',
    generatedLines.join('\n'),
    '',
    content.slice(endMarkerIndex),
  ].join('\n');
}

/**
 * @param {string} content
 * @returns {Promise<string>}
 */
async function updateTools(content) {
  console.log('Loading tool information from compiled modules...');

  const generatedLines = /** @type {string[]} */ ([]);

View on GitHub (pinned to 16cf228d7b)

Solutions

  1. Restore both markers in README.md exactly as the script defines them: check the `startMarker`/`endMarker` template strings in update-readme.js (e.g. `<!--- Tools generated by update-readme.js -->` and `<!--- End of tools generated section -->`) and ensure each appears verbatim, in order, in the README.
  2. If markers were lost, `git checkout HEAD -- README.md` (or copy them from an older tag) to recover the marker lines, then rerun the script.
  3. Never hand-edit content between the markers; place custom prose outside the generated sections so formatters and edits don't disturb the markers.

Example fix

# before (README.md) — end marker corrupted
<!--- Tools generated by update-readme.js -->
...old table...
<!---End of tools generated section--->

# after
<!--- Tools generated by update-readme.js -->
...old table...
<!--- End of tools generated section -->
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify markers exist before invoking the generator:
import fs from 'fs';

const readme = fs.readFileSync('README.md', 'utf-8');
const markers = [
  '<!--- Tools generated by update-readme.js -->',
  '<!--- End of tools generated section -->',
  '<!--- Config generated by update-readme.js -->',
  '<!--- End of config generated section -->',
];
const missing = markers.filter(m => !readme.includes(m));
if (missing.length) {
  console.error('README markers missing:', missing);
  process.exit(1);
}

Type guard

function hasGeneratedMarkers(readme, startMarker, endMarker) {
  const s = readme.indexOf(startMarker);
  const e = readme.indexOf(endMarker);
  return s !== -1 && e !== -1 && s < e;
}

Try / catch

try {
  await updateReadme();
} catch (e) {
  if (/Markers for generated section not found/.test(e.message)) {
    // restore markers from git rather than letting the script rewrite the README
    execSync('git checkout HEAD -- README.md');
    throw new Error('README markers were corrupted; restored from git. Re-apply manual edits outside generated sections.');
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `node utils/update-readme.js` when README.md is missing a marker comment, has a typo in one (e.g. `<!---End of tools generated section -->` missing a space, or `--->`), has the markers reordered (end before start), or when a hand-edit accidentally deleted a marker line. Also triggered by tools that reformat/lint markdown and alter or strip the HTML comments.

Common situations: Manual edits to README.md that touch the generated sections; a merge conflict resolution that drops marker lines; Prettier/markdown formatters normalizing comment syntax; partial reverts where only one of the paired markers was removed.

Related errors


AI-assisted analysis of microsoft/playwright-mcp@16cf228d7b (2026-08-27). Data as JSON: /api/errors/155bc8972b647ae4. Report an issue: GitHub.