Skip to content

fix(rules): robots-meta-conflict counts header noindex and shares one robots.txt decision #556 - #877

Merged
nc9 merged 2 commits into
mainfrom
fix/556-robots-meta-conflict
Oct 16, 2026
Merged

nc9 merged 2 commits into
mainfrom
fix/556-robots-meta-conflict

Conversation

@nc9

@nc9 nc9 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Closes #556

What changed

  • isRobotsTxtDisallowed (utils) now decides "blocked by robots.txt" the way Google does: the crawler's UA group (case-insensitive) with a * fallback, longest matching Allow/Disallow wins, Allow wins a tie, * and trailing $ honoured, path matched with its query string, percent-encoding normalised on both sides. The old logic was first-match prefix only, so Disallow: /dir/ + Allow: /dir/ok blocked /dir/ok, and Disallow: /*.php matched nothing.
  • crawl/robots-meta-conflict drops its private prefix matcher and uses that shared decision, so it and crawl/indexability-conflicts agree on every URL.
  • noindex is read with isPageIndexable (meta tag or X-Robots-Tag), counting only meta:noindex / header:noindex (an unparseable page is not noindex). Header-only noindex is now reported.
  • redundant-noindex lists its pages (report affectedPages).
  • Solution text no longer calls Allow plus noindex confusing. Both docs pages describe how blocking is decided.
  • The CLI test that pinned "first matching rule wins" now pins longest match.

Acceptance criteria

  • Blocked page with header-only X-Robots-Tag: noindex reported, URL in pages
  • One shared decision for both rules, Allow/Disallow/wildcards
  • Solution text and docs no longer describe Allow plus noindex as conflicting
  • Tests in packages/rules/tests/robots-meta-conflict.test.ts: header-only reported, meta reported, allowed (meta or header) not reported, Allow vs longer Disallow agree across both rules; plus an unparseable-page case
  • Docs for both rules describe how blocking is decided
  • Skill: no change needed (the skill links to the rule pages, which carry the new text)

Tests

  • packages/utils/tests/robots-match-556.test.ts (issue fixture, longest match, tie, $, query, UA case, percent-encoding, linear time)
  • packages/rules/tests/robots-meta-conflict.test.ts
  • apps/cli/tests/utils/robots-txt.test.ts

Typecheck (utils, rules), oxlint on changed files, codex review (2 rounds, clean).

@nc9
nc9 force-pushed the fix/556-robots-meta-conflict branch from 24cd3c9 to 94279c5 Compare October 16, 2026 16:17
@nc9
nc9 marked this pull request as ready for review October 16, 2026 16:17
@claude

claude Bot commented Oct 16, 2026

Copy link
Copy Markdown

Reviewed the diff. The matcher is correct on the cases I traced: longest match, Allow wins a tie, *, $, query string, and percent-encoding. The wildcard matching is linear. I couldn't run the tests here. I found nothing that should block the merge.

  • (low) packages/utils/src/robots-txt.ts:44 The * fallback compares r.userAgent === "*" exactly, while the named-agent lookup lowercases. If the parser doesn't lowercase agent names, that's fine for *. The * group is the only one that matters for the fallback, so this is just a consistency note.
  • (low) packages/utils/src/robots-txt.ts:44 The agent match is an exact name. Google also matches a group by the longest product-token prefix, e.g. Googlebot-News falls back to Googlebot. This is fine for the default Googlebot agent, but it's worth a doc note if other agents get passed in.
  • (low) packages/rules/src/security/graphql-probe.ts:232 This caller passes "*" as the agent. It now goes through the longest-match logic, so its behaviour changes too: an Allow can now override a Disallow. That's the right behaviour, but there's no test for it. The changelog says "every rule that asks", so a one-line test or mention would help.
  • (nit) packages/utils/src/robots-txt.ts The normalizeRobotsPath doc comment has one overlong line. There is also a stray blank line left after the removed getPathname import.
  • (nit) packages/utils/tests/robots-match-556.test.ts The 200ms timing assertion for the linear-time test could be flaky on slow CI. Consider a larger input and a looser bound, or assert on correctness only.
  • (nit) docs/rules/crawl/robots-meta-conflict.mdx The docs still say the robots-conflict warn branch is never reached. That is still true, so nothing to change.

Test coverage looks good: a shared-verdict test across both rules, header-only and meta noindex, and an unparseable page.

nc9 added 2 commits October 17, 2026 04:17
… robots.txt decision #556

isRobotsTxtDisallowed now follows Google's matching: UA group with * fallback,
longest match wins, Allow wins ties, * and $ honoured, query included,
percent-encoding normalised. robots-meta-conflict drops its private prefix
matcher, reads meta and X-Robots-Tag noindex via isPageIndexable, and lists
the pages on redundant-noindex.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the fix/556-robots-meta-conflict branch from 94279c5 to 2130d13 Compare October 16, 2026 17:17
@nc9

nc9 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Review triage (94279c5), rebased onto 7bd9bd9 and pushed as 2130d13:

  • (nit) linear-time test bound: loosened to 2 s. A backtracking matcher takes minutes on that input, so it still separates the two. Also dropped the stray blank line after the imports.
  • (low) * fallback compared exactly: the parser keeps the agent as written, and * has no case, so the exact compare is correct.
  • (low) product-token prefix matching (Googlebot-News -> Googlebot): every caller passes Googlebot (the default) or *, so exact group names are enough today. Noted for a future caller.
  • (low) graphql-probe passing *: it now gets longest-match too, which is the intended "every rule that asks" behaviour. The shared matcher is covered by robots-match-556.test.ts, and graphql-probe.test.ts passes on this branch (53/53 across the robots consumers).

@claude

claude Bot commented Oct 16, 2026

Copy link
Copy Markdown

Reviewed the diff. The matcher logic (longest match, Allow wins tie, */$, query string, linear-time wildcard matching) looks correct and the tests cover it well. No blocking problems found.

  • (low) packages/utils/src/robots-txt.ts isRobotsTxtDisallowed is shared by graphql-probe.ts (UA *), all-noindex-pages.ts, schema-noindex-conflict.ts and indexable.ts. Their results change too (longer Allow now wins, wildcards now match, query strings count). The CHANGELOG says this, but only the utils and robots-meta-conflict tests cover it. A regression test for graphql-probe's * path would be worth adding, since it decides whether a probe is skipped.
  • (low) robots-meta-conflict used to read only the * group. It now reads the Googlebot group first, with * as the fallback. This is documented, but sites with a Googlebot-specific group will see different findings after the upgrade.
  • (nit) normalizeRobotsPath doc comment has an over-long line ("...as the URL parser encodes a path), %XX escapes..."). Please rewrap it.
  • (nit) The linear-time test asserts on wall-clock time (<2s). It is generous, but it can still be flaky on a heavily loaded CI box. Asserting that the result is correct on a much larger input would avoid the timing dependency.
  • (nit) robotsPathMatches has no tests for a pattern where $ follows a * with overlapping literals (e.g. /a*a$ against /aa, /a*ab$). The anchored branch's path.length - last.length >= pos check handles these correctly, but a test would pin it.

@nc9
nc9 merged commit 8f21943 into main Oct 16, 2026
15 checks passed
@nc9
nc9 deleted the fix/556-robots-meta-conflict branch October 16, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crawl/robots-meta-conflict: report header-only noindex on blocked pages and share the blocked decision with indexability-conflicts

1 participant