fix: avoid integer overflow in password policy migration#1830
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughMigration updates password policy validation logic to use numeric-based computations instead of integer casting for intermediate values. The normalization CTE and constraint checks are modified to ensure consistent type handling while validating the min_length parameter stays between 6 and 72. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 SQLFluff (4.0.4)supabase/migrations/20260319090430_password_policy_max_length_72.sqlUser Error: No dialect was specified. You must configure a dialect or specify one on the command line using --dialect after the command. Available dialects: Comment |
There was a problem hiding this comment.
💡 Codex Review
I checked git log --follow for this file and 20260319090430_password_policy_max_length_72.sql already existed before this commit, while supabase/migration_guide.md:53 says pushed migrations must be treated as immutable. That means any environment that already recorded version 20260319090430 will never re-run these new ::numeric definitions, so it keeps the old overflowing ::integer casts in orgs_password_policy_config_min_length_check and the Allow update for auth (admin+) policy. In practice this only fixes first-time applies; staging/self-hosted/prod databases that already applied the earlier migration still need a follow-up migration.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|



Summary (AI generated)
Motivation (AI generated)
Production hit while applying the migration because a persisted value exceeded PostgreSQL integer range before the clamp executed. The migration needs to tolerate malformed historical values and normalize them safely.
Business Impact (AI generated)
This unblocks production database deploys for the password policy rollout and prevents a single bad org setting from halting future deploys. It preserves the intended 72-character Supabase Auth limit without requiring manual data cleanup in production.
Test Plan (AI generated)
Generated with AI
Summary by CodeRabbit