test(auth): cover incrementOne/set against a mapped counter column - #1543
Conversation
Extends the mapped rate-limit harness to remap `count` and the bigint `lastRequest` column, then exercises incrementOne's increment and set branches against them, cross-checking with the ORM lane's read and asserting the bigint return narrows to a number the same way the ORM lane does. Confirmed (by temporarily diverging codecFor's column resolution) that these tests fail when incrementOne's column resolution diverges from sqlWhere's. Closes #1241 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QyBL7H6hKQW5HzAkzp8FoY
🦋 Changeset detectedLatest commit: 15545b8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Deployment failed for project stack-docs with the following error: Learn More: https://vercel.com/open-saas?upgradeToPro=build-rate-limit |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The failing Generated by Claude Code |
Review (effort: medium)ScopeTest-only change: extends What checks out
On the "no live bug" claim — it needs qualifying, not retractingTraced The reasoning doesn't generalize as broadly as the PR body implies, though. let f = schema[model]?.fields[field];
if (!f) {
const result = Object.entries(schema[model]!.fields!).find(([_, f]) => f.fieldName === field);
...
}If an app remaps one field's column to a string that happens to equal a different field's own (unmapped) default key in the same model — e.g. This isn't purely theoretical: nothing in Suggested follow-up (not blocking this PR): file an issue to either (a) add a generate-time check in VerdictApprove on the diff as test-only coverage — it correctly closes #1241 and its acceptance criterion. Recommend filing the follow-up issue above given what tracing the resolution path turned up, and tightening the PR body's claim accordingly. 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com Generated by Claude Code |
|
Thanks for tracing that through — good catch on the direct-hit-first ordering in Generated by Claude Code |
Coverage Report for Core Package Coverage (./packages/core)
File CoverageNo changed files found. |
Coverage Report for UI Package Coverage (./packages/ui)
File CoverageNo changed files found. |
Coverage Report for CLI Package Coverage (./packages/cli)
File CoverageNo changed files found. |
Coverage Report for Auth Package Coverage (./packages/auth)
File CoverageNo changed files found. |
Coverage Report for Storage Package Coverage (./packages/storage)
File CoverageNo changed files found. |
Coverage Report for RAG Package Coverage (./packages/rag)
File CoverageNo changed files found. |
Coverage Report for Storage S3 Package Coverage (./packages/storage-s3)
File CoverageNo changed files found. |
Coverage Report for Storage Vercel Package Coverage (./packages/storage-vercel)
File CoverageNo changed files found. |
Summary
mappedAuth adapter test harness (packages/auth/tests/adapter-behaviour.test.ts) to remap the rate-limit list'scountandlastRequestfields, not justkeyincrementOne'sincrementbranch against the mappedcountcolumn, cross-checking the result against a fresh ORM-lane readsetbranch against the mapped,bigint-typedlastRequestcolumn, asserting the returned value narrows to a JSnumberthe same way the ORM lane doescodecFor's column resolution diverge fromsqlWhere's (using the field key instead of the raw column) and confirmed the new tests fail withAuthAdapterError: ... exposes no column "count", then reverted. For the mapped columns this PR exercises (count→hit_count,lastRequest→last_seen), the existingoutward()/getFieldAttributesmachinery round-trips correctly offRETURNING, because better-auth's owngetDefaultFieldNamereverse lookup (byfieldName) resolves a mapped column name back to the right field key.fieldsremap whose target string collides with a different field's own default key in the same model (e.g.{ count: 'total_count', lastRequest: 'count' }) would misresolve. That's a narrow, pre-existing edge case in unchanged production code, out of scope for this coverage PR; tracked in Auth adapter: afieldsremap colliding with another field's default key silently misresolves #1545.Test plan
incrementOnecovered against a mapped columnsetbranch covered against a mapped columncodecFor's column resolution diverges fromsqlWhere'spnpm --filter @opensaas/stack-auth test— 511 passed, 81 skippedpnpm lintpnpm manypkg fix(no changes)pnpm format(no changes)Closes #1241
🤖 Generated with Claude Code
https://claude.ai/code/session_01QyBL7H6hKQW5HzAkzp8FoY