Skip to content

fix(privacy,test): expire every parent cookie domain, correct two stale test claims - #418

Merged
Ducksss merged 1 commit into
devfrom
fix/coderabbit-consent-domains-and-test-contracts
Aug 2, 2026
Merged

Ducksss merged 1 commit into
devfrom
fix/coderabbit-consent-domains-and-test-contracts

Conversation

@Ducksss

@Ducksss Ducksss commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Closes all three CodeRabbit findings from promote #416. I verified each against the source before changing anything — all three were real, though one is less severe than labelled.

1. src/lib/consent.ts — GA withdrawal missed the registrable domain

CodeRabbit rated this Major; it's real but latent, with no live impact, and that distinction is worth stating.

labels.slice(-2) sends www.example.co.uk to co.uk and never example.co.uk, so a _ga cookie on the actual registrable domain survives withdrawal. But for your host, www.payload-components.xyz, slice(-2) already yields payload-components.xyz — the correct domain. It bit only hosts under a two-part public suffix.

Which parent is registrable needs a public-suffix list the browser doesn't expose, so enumerate every parent rather than assuming two labels. That matches the function's own existing design — its comment already says the misses are inert:

-    if (labels.length > 2) {
-      const registrable = labels.slice(-2).join('.')
-      domains.add(registrable)
-      domains.add(`.${registrable}`)
-    }
+    for (let index = 1; index < labels.length - 1; index += 1) {
+      const parent = labels.slice(index).join('.')
+      domains.add(parent)
+      domains.add(`.${parent}`)
+    }

The bare TLD is skipped because no host can set a cookie there. Verified across host shapes:

hostname parents now tried
www.payload-components.xyz payload-components.xyz — unchanged
www.example.co.uk example.co.uk, co.uk — the fix
a.b.example.com b.example.com, example.com
payload-components.xyz none needed (host + .host already in the set)
localhost none

No test pinned the old behaviour: consent.e2e sets its cookies with no domain, which the pre-existing '' entry covers, and this change is purely additive.

2. tests/e2e/frontend.e2e.spec.ts — stale ceiling claim

A comment still called the overrun ceiling "deliberately loose 60px" after #413 tightened it to 50px. One-word fix.

Note I deliberately left line 245 alone — its "It was 60px, but…" is intentional history explaining why it was tightened, not drift. Only the claim about the current value was wrong.

3. tests/int/painted-contrast.int.spec.ts — fixture didn't match the producer

The fixture carried '.stat-value (no glyph pixels)', but the producer pushes the bare selector (painted-contrast.ts:572) and the report label supplies the reason — so the expected output was a string the producer never emits.

The two lists genuinely differ in shape, which is what makes this easy to get wrong in either direction: unresolvedSelectors is pushed pre-suffixed (:229, :233), so that fixture is correct and I left it untouched. I wrote the asymmetry into the comment so the next edit doesn't "fix" the wrong one.

Scope note, to avoid overclaiming: this makes the fixture faithful to what the producer emits. It does not couple the two — the spec imports only formatPaintedContrastReport and never calls measurePaintedTextContrast, which needs a browser. A producer-side shape change still wouldn't fail this spec; closing that would need a different test.

Verification

lint, format:check, tsc --noEmit, test:int (32 files / 379 tests) all green locally. The consent behaviour itself is covered by consent.e2e in release-gate.

…le test claims

Closes the three CodeRabbit findings on promote #416. Each was verified against
the source before changing anything.

1. src/lib/consent.ts — GA cookie withdrawal missed the registrable domain on
   multi-label public suffixes. `labels.slice(-2)` sends `www.example.co.uk` to
   `co.uk` and never `example.co.uk`, so a cookie on the real registrable domain
   survived withdrawal. Which parent IS registrable needs a public-suffix list
   the browser does not expose, so enumerate every parent instead of assuming
   two labels — matching the function's existing "the misses are inert" design.
   The bare TLD is skipped since no host can set a cookie there.

   Latent rather than live: for `www.payload-components.xyz`, `slice(-2)` already
   yielded `payload-components.xyz`, the correct domain. It bit only hosts under
   a two-part suffix. Verified the new enumeration across host shapes —
   `www.example.co.uk` now reaches `example.co.uk`, `a.b.example.com` reaches
   both parents, `payload-components.xyz` and `localhost` are unchanged.

   No test pinned the old behaviour: consent.e2e sets its cookies with no domain,
   which the pre-existing `''` entry covers, and the change is purely additive.

2. tests/e2e/frontend.e2e.spec.ts — a comment still called the overrun ceiling
   "deliberately loose 60px" after #413 tightened it to 50px. The neighbouring
   line 245 reference is deliberate history ("It was 60px, but…") and is left
   alone; only the claim about the current value was wrong.

3. tests/int/painted-contrast.int.spec.ts — the fixture carried
   `'.stat-value (no glyph pixels)'`, but the producer pushes the bare selector
   (painted-contrast.ts:572) and the label supplies the reason. The two lists
   genuinely differ in shape — `unresolvedSelectors` IS pushed pre-suffixed
   (:229, :233), so that fixture is correct and untouched — and the asymmetry is
   now written down so the next edit does not "fix" the wrong one.

   Scope note: this makes the fixture faithful to what the producer emits. It
   does not couple the two — the spec imports only `formatPaintedContrastReport`
   and never calls `measurePaintedTextContrast`, which needs a browser.

Local: lint, format:check, tsc --noEmit, test:int (32 files / 379 tests) green.
The consent behaviour itself is covered by consent.e2e in release-gate.

Co-Authored-By: Claude Opus 5 <[email protected]>
Copilot AI review requested due to automatic review settings July 30, 2026 10:30
@vercel

vercel Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
payload-components Ready Ready Preview Jul 30, 2026 10:36am
payload-components-97bf Ready Ready Preview Jul 30, 2026 10:36am

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Ducksss, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 785debb2-8086-4563-a7cf-633a24774272

📥 Commits

Reviewing files that changed from the base of the PR and between 60939c7 and 0515dc8.

📒 Files selected for processing (3)
  • src/lib/consent.ts
  • tests/e2e/frontend.e2e.spec.ts
  • tests/int/painted-contrast.int.spec.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Ducksss
Ducksss merged commit 3bffaec into dev Aug 2, 2026
12 checks passed
@Ducksss
Ducksss deleted the fix/coderabbit-consent-domains-and-test-contracts branch August 3, 2026 08:49
Ducksss added a commit that referenced this pull request Oct 1, 2026
#585)

Every docs page threw minified React #418 (server-rendered text did not
match the client) in production. Docs pages are prerendered at their
internal route (/en/docs/...) and served at the public URL (/docs/...).
fumadocs-ui/provider/next hands Fumadocs next/navigation's pathname, which
reads /en/docs while prerendering and /docs in the browser. Fumadocs
matches its chrome against that pathname, so the static HTML missed the
page tree: the mobile TOC trigger said "On this page" where the client
rendered the page title, and the prev/next footer and breadcrumb were
missing. pnpm dev renders on request at the public URL, so it never
reproduced.

publicPathname() maps a route pathname to the URL the browser shows, and
FumadocsRootProvider wires Fumadocs to Next.js like the stock provider
except for that pathname. The docs and blog layouts use it. The blog had
no pathname-derived chrome, but it sat on the same stock provider.

The new frontend e2e check fails on the unfixed production build with the
#418 error and passes with the fix. The int spec covers publicPathname and
rejects stock-provider imports.

Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch was successfully deployed

2 active deployments
Preview – payload-components-97bf — 0515dc83 Deployed Jul 30, 2026 by vercel[bot]
Preview – payload-components — 0515dc83 Deployed Jul 30, 2026 by vercel[bot]
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.

2 participants