fix: resolve three open bugs (#278, #280, #281)#285
Merged
Conversation
- #281: Replace fragile exact call-count assertion in migration test with toBeGreaterThan(0), relying on per-DDL string assertions for coverage - #280: Add requireCampaignConfigsReady lazy-retry guard to all /api/admin/automated-campaigns routes, matching the existing requireConditionsReady pattern - #278: Add Zod schema validation to POST /api/admin/error-logs/batch-delete request body, rejecting invalid types and unexpected properties with 400 https://claude.ai/code/session_01QqzNhpF5Qy7W8vrxiFfmgD
Add tests verifying that extra top-level and nested properties are rejected by the strict Zod schema. Also apply .strict() to the nested filters object for consistent validation. https://claude.ai/code/session_01QqzNhpF5Qy7W8vrxiFfmgD
Prevent oversized SQL IN clauses from unbounded array inputs. https://claude.ai/code/session_01QqzNhpF5Qy7W8vrxiFfmgD
- Reject excludeIds when combined with ids (was silently ignored) - Move empty-filters check into Zod refine for consistent error format - Add test for excludeIds + ids rejection https://claude.ai/code/session_01QqzNhpF5Qy7W8vrxiFfmgD
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR fixes three distinct issues: missing Zod schema validation on the batch-delete error-logs endpoint, a missing lazy-retry guard for automated campaign admin routes that fail silently after transient startup errors, and a fragile exact call-count assertion in migration tests that breaks when new ensure functions are added. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
This was referenced Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three open GitHub issues: fragile migration test assertion (#281), missing lazy-retry guard on campaign admin routes (#280), and missing Zod schema validation on the batch-delete error logs endpoint (#278). All changes are backend-only with no user-facing impact.
Changes
#281 — Fragile migration test assertion
toHaveBeenCalledTimes(25)withtoBeGreaterThan(0)inserver/routes.migration.test.ts#280 — Missing lazy-retry guard for campaign admin routes
requireCampaignConfigsReadyfunction mirroring the existingrequireConditionsReadypattern/api/admin/automated-campaignsroutes (GET, PATCH, POST trigger)campaignConfigsReadyfromconsttoletto allow lazy mutation on retry#278 — Missing Zod validation on batch-delete error logs
batchDeleteSchemawith Zod validation: typedids,filterswith enum validation,excludeIds,.strict()on both outer and nested objects.refine()ensures exactly one ofidsorfiltersis provided.refine()rejectingexcludeIdswhenidsis present (was silently ignored).refine()for consistent error formatidsandexcludeIdsarrays at 500 to prevent oversized SQL IN clausesTests
How to test
npm run check && npm run test— all 1827 tests passnpm run build— production build succeeds{ ids: [1], extraProp: true }→ 400{ ids: [1,2], excludeIds: [1] }→ 400{ filters: {} }→ 400Closes #278, closes #280, closes #281
https://claude.ai/code/session_01QqzNhpF5Qy7W8vrxiFfmgD
Summary by CodeRabbit
Bug Fixes
Improvements
Tests