fix: coerce is_telemetry_enabled form values on instance admin signup#9415
Open
pranav-afk wants to merge 1 commit into
Open
fix: coerce is_telemetry_enabled form values on instance admin signup#9415pranav-afk wants to merge 1 commit into
pranav-afk wants to merge 1 commit into
Conversation
Form-encoded signup can post is_telemetry_enabled as the string false or true. Assigning that string to a BooleanField caused save() to 500 after creating the admin user, leaving the instance half-configured. Coerce the value to a real bool before writing. Writes already run in transaction.atomic. Fixes makeplane#9370
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe admin sign-up endpoint now converts the ChangesTelemetry flag normalization
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 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.
Description
Fixes instance admin first-run signup when is_telemetry_enabled is posted as a form string.
POST /api/instances/admins/sign-up/ reads telemetry from the form:
is_telemetry_enabled = request.POST.get("is_telemetry_enabled", True)
When the field is omitted, the default is a real bool. When the form sends is_telemetry_enabled=false / true, Django returns a string. That string was assigned to Instance.is_telemetry_enabled (BooleanField) and instance.save() could 500.
Because the handler creates the user and InstanceAdmin before that save, a failure left the instance half-configured:
• user + instance admin created
• instances.is_setup_done never set
• retry → ADMIN_ALREADY_EXIST
• normal login → INSTANCE_NOT_CONFIGURED
• no UI/API recovery without a manual DB update
Change: coerce form values to a real boolean before assignment:
• already a bool → keep as-is
• otherwise treat truthy strings as true: 1, true, yes, on (case-insensitive)
• everything else (including "false") → False
User/admin/instance writes already run inside transaction.atomic(), so a later failure no longer strands a partial admin signup the same way.
Type of Change
• [x] Bug fix (non-breaking change which fixes an issue)
• [ ] Feature (non-breaking change which adds functionality)
• [ ] Improvement (change that would cause existing functionality to not work as expected)
• [ ] Code refactoring
• [ ] Performance improvements
• [ ] Documentation update
Screenshots and Media (if applicable)
N/A — backend auth/bootstrap only.
Test Scenarios
• Fresh instance (no admin, is_setup_done false)
• Sign up with is_telemetry_enabled=false (form-encoded) → 200 redirect, setup completes, can sign in
• Fresh instance again: omit is_telemetry_enabled → defaults to enabled, setup completes
• Sign up with is_telemetry_enabled=true / True / 1 → telemetry stays enabled
• Confirm instances.is_setup_done is true and is_telemetry_enabled matches the intended value
• Confirm a second signup still returns ADMIN_ALREADY_EXIST (guard unchanged)
References
• Fixes #9370
• Related: #8828 (same endpoint / telemetry form string pattern)
Summary by CodeRabbit