cd /news/ai-crawlers/our-robots-txt-check-could-never-fai… · home › topics › ai-crawlers › article
[ARTICLE · art-180858] src=dev.to ↗ pub= topic=ai-crawlers verified=true sentiment=· neutral

Our robots.txt check could never fail, because "disallow: /" contains "allow: /"

A developer behind the free SEO audit tool StitchSEO found and fixed two bugs in its robots.txt parsing, both of which caused the check to report sites as crawlable when they actually blocked bots. The first bug let a regex for an Allow: / line match inside Disallow: /, cancelling the block detection, while the second let a per-bot regex run past a bot's own user-agent group and misreport GPTBot as blocked. The developer published a rewritten parser that groups consecutive User-agent lines and applies only the matching bot's rules, plus ten test cases covering both failure modes.

recommendation

Parse robots.txt into per-user-agent groups and match Allow/Disallow as whole directives rather than substrings, then run the source's ten test cases against your own crawler check.

more in playbook: Designing agent systems
by read2 min views5 publishedDec 3, 2026

We launched StitchSEO, our free one-page SEO audit, on Product Hunt today. While checking our own launch claims we found two bugs in how it read robots.txt.

The check looked like this:

const blocksAll = /user-agent:\s*\*[\s\S]*?disallow:\s*\/\s*(\n|$)/i.test(robotsTxt)
  && !/allow:\s*\//i.test(robotsTxt);

The second test was meant to spot an Allow: / line. But the string Disallow: / contains allow: /. So whenever the first half matched, the second half cancelled it, and a site that blocked every crawler still passed.

For AI crawlers we built a regex per bot:

new RegExp(`user-agent:\\s*${bot}[\\s\\S]*?disallow:\\s*/\\s*(\\n|$)`, 'i')

The lazy [\s\S]*? happily runs past the end of the bot's own group. With this file, GPTBot was reported as blocked:

User-agent: GPTBot
Allow: /

User-agent: BadBot
Disallow: /

Read the file the way a crawler does: use the group that names you, or the * group if none does, and remember that consecutive User-agent lines share the rules below them.

export function blockedFromSite(robotsTxt: string, bot: string): boolean {
  const groups: { agents: string[]; rules: string[] }[] = [];
  let readingAgents = false;
  for (const line of robotsTxt.split(/\r?\n/)) {
    const m = /^\s*([a-z-]+)\s*:\s*([^#]*)/i.exec(line);
    if (!m) continue;
    const key = m[1].toLowerCase();
    const value = m[2].trim();
    if (key === 'user-agent') {
      if (!readingAgents) groups.push({ agents: [], rules: [] });
      groups[groups.length - 1].agents.push(value.toLowerCase());
      readingAgents = true;
    } else if (key === 'allow' || key === 'disallow') {
      groups[groups.length - 1]?.rules.push(`${key}:${value.replace(/^\/\*$/, '/')}`);
      readingAgents = false;
    }
  }
  const own = groups.filter((g) => g.agents.includes(bot.toLowerCase()));
  const rules = (own.length ? own : groups.filter((g) => g.agents.includes('*'))).flatMap((g) => g.rules);
  return rules.includes('disallow:/') && !rules.includes('allow:/');
}

It only answers one question, whether a bot is shut out of the whole site. It doesn't evaluate path rules.

We added ten small test cases, including both files above. If you have a robots.txt check of your own, try them on it.

The tool is at saraswatistitch.com/seo-audit if you want to break it.

Written with AI assistance. Code and behaviour checked against our repository.

── more in #ai-crawlers 4 stories · sorted by recency
── more on @stitchseo 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/our-robots-txt-check…] indexed:0 read:2min 2026-12-03 · —