Skip to content

fix(report): a captcha-blocked widget reports to nobody - #396

Merged
sydevs-bot merged 6 commits into
mainfrom
claude/fix-387-report-captcha-blocked
Nov 12, 2026
Merged

sydevs-bot merged 6 commits into
mainfrom
claude/fix-387-report-captcha-blocked

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • A captcha-blocked failure now sends one Sentry event. It took the whole widget down and told nobody.
  • The reason stated beside the flag was false for this path, and a comment in Fallbacks.tsx repeated it.

Change outline

One row is the whole gate, and the console level reads the same row — so the flip moves two signals.

 REPORTED_KINDS                                        src/lib/report.ts
   offline: false            # no network left to carry the POST
   not-found: false          # somebody's stale bookmark
   server: true
   config: true
-  captcha-blocked: false    # "the report POST is itself Turnstile-gated"
+  captcha-blocked: true
   unknown: true

 reportInternalError(error, context)
   kind = classifyError(error)
   REPORTED_KINDS[kind] ? console.error : console.warn  # was warn for this kind
   captureError(error, kind, context)
     returns before loadReporter unless REPORTED_KINDS[kind]
     scope.clone().setTag('atlas.kind', kind)           # unchanged, and now pinned per kind

The claim the row carried was true of one channel and false of the other:

 what carries a captcha-blocked failure
-  the visitor's report form     # Turnstile-gated, so it cannot submit — still withheld
+  the Sentry DSN's transport    # nothing in it touches the challenge gate

Preview

  • No visual surface: the diff changes a reporting gate, a console level and comments, so every page renders as it did. Branch alias: preview pending.

Contract impact

A host observes two things, both now in CHANGELOG.md: one more POST to *.sentry.io after the widget has already failed, and an error-level console line beside the warning that already named the fix. No parameter, origin, CSP or Permissions-Policy change — connect-src https://*.sentry.io already covers it, and a host that left that origin out gets the behaviour its own row already promises (one refused request, then the widget stops for the page's life). So docs/embedding.md needed no edit — its troubleshooting row already sends a host developer to the console line that names both fixes — and the two in-tree consumers (WeMeditateWeb/lib/atlas-embed.ts, the WordPress templates) need nothing.

Test results

  • Lean gate: ✓ .claude/skills/pr-prep/check.sh — lint, typecheck, 2002 tests in 166 files. Re-run after the review revision, unchanged.
  • Targeted specs: report.sentry.test.ts 21 passed, report.test.ts + Fallbacks 60 passed
  • Build: ✓ pnpm build + pnpm size — standalone 327.3/330, loader 2.5/3.2, embed 329.2/330 KiB. Measured before the review revision, which touches a changelog line, a comment and a spec, so it emits the same bundle.

Manual verification

  1. On a build carrying VITE_SENTRY_DSN, block the challenge — embed on a host no client record lists, or send a CSP without frame-src https://cloud.sydevelopers.com — and confirm one event arrives in the sahajatlas-web project tagged atlas.kind: captcha-blocked.
  2. On that page, confirm the screen is unchanged: the same message, a retry, and no report action.
  3. Worth knowing before you trust the signal: a host that blocks frame-src to SahajCloud is a plausible candidate to have left connect-src *.sentry.io out too, and then the event is swallowed by the transport's refusal latch. The CSP half of this failure may stay partly invisible from the client side.

Notes for reviewer

  • The question on the row is settled: A, the option already built. A captcha-blocked embed reports once per broken pageview, accepted because config has the same profile and Sentry groups the events into one issue. B was declined because a refused frame-src never reaches SahajCloud, so it cannot see the CSP half of this failure; C because its per-visitor latch needs a fifth storage key on the host origin, which throws in the sandboxed embeds likeliest to block the challenge.
  • Two console lines carry this failure, and the second one is the one that moved. use-turnstile-guard warns first, through reportIntegrationWarning, with the advice naming both causes and the troubleshooting link. reportInternalError then logs the kind, and that is the line now at error level. One table decides both of its signals by design; splitting them would be a change to the seam, not to this row.
  • Nothing was added to bound the noise, deliberately. dedupeIntegration, MAX_EVENTS_PER_PAGE and the transport's one-shot refusal latch were already on this path, and the rule is to name an exposure rather than build machinery against an unmeasured one.
  • Dismissed, with reasons. (a) sent increments before the SDK's dedupe, so repeat "Try again" presses spend page-wide event slots on events that are then dropped — a pre-existing property of where the counter lives, and this screen is dead at the top boundary so there is rarely a later distinct failure to starve; moving the counter is a change to the seam. (b) Dropping the new per-kind tag assertion as derivable — it is not: replacing setTag('atlas.kind', kind) with a constant reddens three rows, and the dedicated tagging case covers config only. (c) vi.waitFor's 50 ms default poll is most of this spec's runtime — true, and a whole-file tidy rather than this row's business.
  • A stale comment at Fallbacks.tsx claimed REPORTED_KINDS mirrored the withheld report button. The line is gone rather than corrected: report.ts's table doc states the contrast at the row it governs, and a second copy here rebuilds the defect this PR fixes. Against the base that deletes a line and carries no breadcrumb away.
  • Fixture pre-mortem: the spec's @sentry/browser mock assumes loadReporter builds a BrowserClient, clones a child Scope per event and tags through setTag('atlas.kind', kind), and that the kind gate runs before the SDK import. Verified against src/lib/report.ts:481-497 and :533.
Detail

Watched red before kept. Three times, each at the site that caused it. The new row fails against REPORTED_KINDS['captcha-blocked']: false (expected [] to have a length of 1). The per-kind tag assertion fails on its own when setTag('atlas.kind', kind) becomes a constant (config, captcha-blocked, unknown redden). The withheld rows' absence assertion fails when the kind gate is dropped from captureError alone (expected [ 'offline' ] to deeply equal []) — before the microtask flush this branch adds, that defect passed. Dropping a kind from the spec's table fails pnpm typecheck with TS2741 rather than passing silently.

The alternative, weighed and not taken here. SahajCloud's /api/atlas/challenge already answers 403 and already knows the parent host, so it could log every refusal with no client traffic at all. That is the cheaper census, in a different repo, and it does not replace this half: only the client knows a visitor actually saw the broken screen. The ticket leaves the roadmap promotion to a human.

Privacy, re-verified rather than assumed. No field travels for this kind that was not already travelling for server, config and unknown: beforeSend rebuilds event.tags to three keys and event.request to hostPageUrl() (origin and path), and deletes user, extra, contexts, breadcrumbs and any attachment. The thrown message is a fixed literal, with no cause for linkedErrors to walk. Both console branches pass identical arguments, so the level change discloses nothing new.

Review passes. /simplify (reuse, simplification, efficiency, altitude) and /code-review high — no pr-review-toolkit in a routine. /security-review ran twice, because src/lib/report is in this repo's securityReview.triggerPattern: no finding either time. comment-lint.mjs: no banned comment added. Per-edit spec selection is unchanged from the base — the spec's rows come from its own EXPECTED table, so nothing imports @/mocks/errors there.

Closes #387


Generated by Claude Code

`REPORTED_KINDS['captcha-blocked']` was `false`, so the failure that takes
the whole widget down produced no event and no red console line — only a
warning on the host's own page. Since the challenge gate went live and
keyed to a host allowlist, that is the widget's most likely production
failure and the one it could not observe.

The reason stated beside the flag did not hold for this path: it claimed
the report POST is Turnstile-gated, which is true of the visitor-facing
report form and false of `captureError`, which posts to the Sentry DSN
over `@sentry/browser`'s own fetch transport. The JSDoc now carries the
true reason, and the row carries none.

Noise is bounded by what is already there: `dedupeIntegration`,
`MAX_EVENTS_PER_PAGE`, and a transport that latches off after one
refusal. `ERROR_POLICY` is untouched, so the visitor still sees the same
message and the same retry.

The spec's table now types itself `Record<ErrorKind, boolean>`, so every
kind is a row and a seventh kind is a type error rather than an untested
one. Watched the new row fail against `false` before keeping it.

Closes #387

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXhFSdJJTUYwFBrNyR
…ergence

The spec's table iterates `mockErrorKinds`, the enumeration `report.test.ts`
and `Fallbacks.test.tsx` already share, instead of a local cast — and lists
its rows in `REPORTED_KINDS`' own order, so two hand-kept copies read
alike.

`Fallbacks.tsx` claimed `REPORTED_KINDS` mirrored the withheld report
button. It no longer does, and a line that says otherwise is how the row
gets flipped back.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXhFSdJJTUYwFBrNyR
An absence assertion that settles synchronously passes for a row whose
event arrives one microtask later, so only the console counters were
holding `offline` and `not-found`. Verified: dropping the kind gate from
`captureError` alone now reddens both rows on the capture itself.

The changelog entry also claimed too much. A host that left
`*.sentry.io` out of `connect-src` now makes one refused request on such
a page where it made none, which is what that CSP row's own degrade
column describes.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXhFSdJJTUYwFBrNyR
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design 02c212f Nov 12 2026, 04:45 AM

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

1 question for the reviewer, one per thread.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/lib/report.ts Resolved
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot

sydevs-bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 15:45Z address-review · attempt 1 · session · done
  • 15:45Z address-review · attempt 1 · session
  • 15:34Z address-review · attempt 1 · session · done
  • 15:34Z address-review · attempt 1 · session
  • 04:36Z address-review · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 12, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🧐 Adversarial review

The diff is the size of its ticket: one row flipped, two false comments corrected, the spec table made exhaustive. Nothing is smuggled in — the Fallbacks.tsx and mocks/errors.ts edits are joined by the change that falsified them. The contract claim holds: docs/embedding.md:904 lists *.sentry.io under connect-src, and :931 says it is reached only after the widget has failed. The open question at report.ts:210 is the right one. One datum it omits: this file's reportIntegrationWarning doc argues per-pageview recurrence as grounds for staying console-only, which favours B or C over A. No blockers.

Findings

  • should-fix — CHANGELOG.md:151: of the two console lines here, the one naming the fix stays a warning.
  • should-fix — Fallbacks.tsx:239: the rationale lives in two files again, the shape of the fixed defect.
  • consider — report.sentry.test.ts:165: EXPECTED is already exhaustive, so the mockErrorKinds import adds a second source for the rows.

What was checked

  • Read on the branch: report.ts whole, the ERROR_POLICY captcha row, mocks/errors.ts, the spec, use-turnstile-guard.ts.
  • Ladder: EXPECTED earns its place, since REPORTED_KINDS is module-private; the setTimeout(0) flush has no synchronous substitute — sdk.clients fills only after the dynamic import resolves. The import does not.
  • Contract side: docs/embedding.md's CSP table and captcha troubleshooting row, public/_headers (no CSP of its own), docs/rules/i18n-and-state.md:350 (names only offline and not-found as withheld — still true). The two out-of-tree consumers sit outside this session's scope, and no attribute or origin changed.
  • Grepped every REPORTED_KINDS and captcha-blocked reference for a claim this flip falsifies. The two it corrects are the only two. No preview link to open.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread CHANGELOG.md Resolved
Comment thread src/lib/report.sentry.test.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 12, 2026
Two console lines carry a captcha-blocked failure, and only the second
one changed level. `use-turnstile-guard` warns first, through
`reportIntegrationWarning`, with the advice that names both causes and
the troubleshooting link. `reportInternalError` then logs the kind, and
that is the line now at error level.

"the console line is an error rather than a warning" read as if the
single line had changed, so a host developer filtering their console to
errors would expect the fix in it. It is not there.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYUvKVPgWUBAazYsAy
The defect behind #387 was one claim living in two files, and correcting
the copy here rebuilds the thing that went stale. `report.ts`'s
`REPORTED_KINDS` doc now states the contrast at the row it governs: the
viewer's form is Turnstile-gated, the Sentry DSN's transport is not.

`ERROR_POLICY` owns why this row offers no report action, which the
block above already says. What the reporter does is not its business.

Net against the base this deletes the line and carries no breadcrumb
away: the version on main claimed the mirror with no reference at all.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYUvKVPgWUBAazYsAy
`EXPECTED` is `Record<ErrorKind, boolean>`, so typecheck already makes
it exhaustive — which is what its own doc claims. Its keys are therefore
the same rows, from one source, and match the idiom `mocks/errors.ts`
uses a line below `mockErrors`.

The import bought nothing: the fixtures went unused, since each row
builds its own `atlasError(kind, …)`. It also widened the per-edit
hook's spec selection for `src/mocks/errors.ts`, which now stays as it
was.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYUvKVPgWUBAazYsAy
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Three critic findings, all adopted.

  • CHANGELOG.md:151 — the bullet now names the warning that carries the fix, so the new error line is not mistaken for it. 1b14fdc
  • Fallbacks.tsx:239 — the duplicated rationale is deleted. report.ts's table doc owns it. b9fd45f
  • report.sentry.test.ts:165 — rows come from EXPECTED's own keys, and the @/mocks/errors import is gone. 02c212f

The open question on the row still waits on you, now carrying one datum against option A: reportIntegrationWarning's doc argues per-pageview recurrence as grounds for staying console-only.

Lean gate green — lint, typecheck, 2002 tests in 166 files. /security-review re-ran for src/lib/report: no finding. Body refreshed where this push made it false.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review November 12, 2026 04:48
@sydevs-bot
sydevs-bot requested a review from Ardnived November 12, 2026 04:48
@sydevs-bot
sydevs-bot enabled auto-merge November 12, 2026 04:48
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 12, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 12, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Answered the open question with the recommendation and per-option implications you asked for: A, the built option, stands. Two facts decided it.

  • B cannot see the CSP half of this failure at all. A frame-src refusal blocks the frame navigation, so SahajCloud is never asked. Its other half, the allowlist refusal, is already reported traffic-free by SahajCloud's scripts/audit-challenge-parents.ts (fix(atlas): give every live embed host a service domain, which the captcha now requires SahajCloud#1077).
  • C no-ops where it is needed most. It needs a fifth storage key on the host's origin, so a row in docs/embedding.md § Privacy, and storage throws in a sandboxed embed's opaque origin — the hosts likeliest to block the challenge.

Measured for the performance line: the lazily imported @sentry/browser chunk is 19.4 kB gzip, 57.7 kB raw, fetched once per broken pageview on a build carrying a DSN.

Nothing pushed. The branch is already level with main, and the thread stays open for your call.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 12, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 12, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 12, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

One thread, answered and resolved.

  • report.ts:210 — you chose A, which is the option already built at 02c212f. REPORTED_KINDS['captcha-blocked'] is true, so a blocked embed reports once per broken pageview.

Nothing pushed: the answer needed no code change, and the branch is already level with main.

## Notes for reviewer now records the decision and why B and C were declined, in place of the bullet that said the question was open.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 12, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 12, 2026
Merged via the queue into main with commit e4d9487 Nov 12, 2026
131 of 139 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-387-report-captcha-blocked branch November 12, 2026 15:52
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(report): a captcha-blocked widget reports to nobody

3 participants