Repository navigation
Description
Summary
main fails one unit test at f823484. Two PRs fixed the same defect by different routes and each was green on its own base: #922 narrowed URL_PATTERN so no email address reads as a link, and #919 exempted email-typed form blocks from the scan. #919's new spec probes the free-text scan with an email address, which #922 had already stopped matching.
Approach
The failure:
tests/unit/submission-data.spec.ts > checkSubmissionData content checks
> still URL-scans an address question authored as a text block
TypeError: Cannot read properties of undefined (reading 'code')
tests/unit/submission-data.spec.ts:279 feeds howDidYouHear the value [email protected] and expects urls_not_allowed. URL_PATTERN (src/lib/antiSpam/antiSpamGuard.ts:146) now carries (?<[@a-z0-9.-]) on its bare-domain arm, so an address's domain half no longer matches. problems is empty and problems[0]!.code throws.
The behaviour under test is intact; only the probe is stale. Measured against the shipped pattern:
| value | matches |
|---|---|
[email protected] |
no |
see example.com |
yes |
buy-now.example.com |
yes |
[email protected] buy at cheap.shop |
yes |
So a free-text answer carrying a real link is still refused, which is what the spec's name and its comment claim. Replacing the probe with a link-shaped value restores a test that tests something.
Two things worth settling while the file is open:
- The sibling case at
tests/unit/submission-data.spec.ts:255passessee example.comtocontactAddressand expectsinvalid_email. Check the two cases still partition the space they mean to. - fix(api): stop refusing a visitor's email answer as a URL #919's block-type exemption may now be dead weight: once the pattern excludes every address, exempting email-typed blocks changes no outcome. Decide whether it stays as defence in depth or goes — do not remove it without a case that distinguishes the two.
Acceptance criteria
-
pnpm test:unitis green onmain. - The restored case fails when
(?<[@a-z0-9.-])is deleted fromURL_PATTERN, and when the free-text scan is removed. - No production behaviour changes, or the change is stated and covered.
Verification checklist
-
pnpm exec vitest run tests/unit/submission-data.spec.ts --project unit --config ./vitest.config.mts— 24 passed. -
pnpm test:unit— no failures. - Reintroduce the defect: delete the lookbehind from
src/lib/antiSpam/antiSpamGuard.ts:146and confirm the case goes red, then restore. -
.claude/skills/pr-prep/check.shgreen.
Notes
Found by the audit-deps run on 2026-10-12, which hit the failure in its lean gate and reproduced it at f823484 with its own branch stashed. Not caused by that branch.
The root cause is upstream of the test: #899 and #921 were two tickets for one defect, and each PR's CI only ever saw its own base. Worth a look at whether the duplicate ticket was avoidable.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Hold Until
Projects
- StatusShow more project fieldsDone
Activity