Repository navigation
Description
Summary
The smoke lane can pass having tested a different commit than the one under review. pick() accepts any hostname that is, or ends with, the configured project host — which matches both the per-deploy alias (cad41df8.sahajatlas.pages.dev) and Cloudflare's stable branch alias (fix-i18n-hygiene.sahajatlas.pages.dev). The branch alias points at whatever deployed to that branch most recently, which on a re-push or a queued build is not the PR's head commit.
Found by the security review on #132 and rated High there. It is pre-existing and was an explicit non-goal of that ticket (a timeout fix should not quietly change which URL is trusted), so it was recorded rather than patched.
Why it matters more than it used to
Three gates now lean on this lane meaning something:
- chore(build): add audit gate, size budget, and embed smoke tests #99 made a missing preview hard-fail a same-repo PR, on the premise that a green Smoke check implies the specs ran.
- feat(seo): prevent direct indexing of the standalone build #106 added smoke specs asserting
robots.txtcontent-type and body — the indexing policy is now verified only here. - chore(build): make preview discovery survive a slow cloudflare deploy #132 added
preview_statusso a slow deploy is distinguishable from an absent one.
All three are weakened by a URL that may not correspond to the commit. A stale-but-healthy preview turns the lane into a check that passes for the wrong artifact — the same class of defect as #99's "status is not a result", one level up.
Current behaviour
scripts/get-cloudflare-preview-url.mjs—shortSha(line ~122) is used only to corroborate a Cloudflare bot comment (~line 435). It never constrains which harvested URLpick()returns.pick()(~line 309) matches on hostname suffix alone.- The check-run source added in fix(build): find the preview URL on the check run, not just a comment #122 is fetched per-SHA (
/commits/<sha>/check-runs), so URLs from that source are already commit-correct — the exposure is the comment and any other source that can surface a branch-scoped URL.
Proposed changes
Verify each point against the current file first; #132 rewrote much of it.
- Prefer a deploy-specific URL over a branch alias, rather than taking the first match. The per-deploy alias is the one that corresponds to a commit.
- Where a URL's provenance is already per-SHA (the check run), keep it; where it isn't, either corroborate it against the head SHA or rank it below one that is.
- Consider asserting the served build actually is the head commit — the smoke lane could check a build-stamped asset rather than trusting the URL's provenance at all. That would close the class rather than this instance, and is worth weighing against its cost.
- Do not regress chore(build): make preview discovery survive a slow cloudflare deploy #132's status taxonomy or chore(build): add audit gate, size budget, and embed smoke tests #99's hard-fail: a correct URL that is merely slow must still read as
pending, notabsent.
Acceptance criteria
- A branch-alias URL is not selected when a deploy-specific URL for the head SHA is available
- Discovery still succeeds on the sources fix(build): find the preview URL on the check run, not just a comment #122 and chore(build): make preview discovery survive a slow cloudflare deploy #132 added, exercised against a real recent PR SHA
-
preview_statusstill distinguishes pending / unreachable / absent / failed - The invariant is written down in
.claude/rules/tests.mdalongside the two already there - Write an implementation report to
.claude/reports/<issue-number>-<slug>.mdin the MAIN checkout at/Users/devindra/Documents/Projects/SahajAtlasWeb(the folder is gitignored)
Files affected
scripts/get-cloudflare-preview-url.mjs.claude/rules/tests.md(smoke section)- possibly
tests/smoke/and.github/workflows/ci.yml
Parallel implementation: this ticket owns those files. Sibling release-hardening tickets run concurrently; avoid edits outside them.
References
- Raised by the security review on chore(build): make preview discovery survive a slow cloudflare deploy #132; see
.claude/reports/132-preview-discovery-timeout.md - fix(build): find the preview URL on the check run, not just a comment #122 added the check-run source; chore(build): add audit gate, size budget, and embed smoke tests #99 made a missing preview hard-fail; feat(seo): prevent direct indexing of the standalone build #106's robots specs depend on this lane
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Activity
fix(ci): drop the url input, so the host is always the literal