Repository navigation
Fix: admin password update crashes for SSO users (500 'NoneType' object has no attribute 'split') - #16914
Conversation
SSO-provisioned accounts (OIDC/OAuth) have no local password, so `usr.password` is None. `check_password_hash(None, psw)` then crashes inside werkzeug with "'NoneType' object has no attribute 'split'", returning a 500 when an admin sets a password for such a user. Guard the equality check with `usr.password` so a passwordless user skips straight to setting the new password. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
📝 WalkthroughWalkthrough
ChangesPassword update handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
admin/server/services.py (1)
120-123: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression coverage for both password states.
Please add a focused test proving that
usr.password is Noneupdates successfully, while an existing hash still returns"Same password, no need to update!"without persisting an unnecessary change.As per coding guidelines, “Preserve valid behavior with focused tests.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@admin/server/services.py` around lines 120 - 123, Add focused regression coverage for the password-update logic around the usr.password check: verify users with usr.password set to None update successfully, and users with an existing matching hash return "Same password, no need to update!" without persisting a change. Reuse the existing service and test fixtures/helpers rather than broadening the test scope.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@admin/server/services.py`:
- Around line 120-122: Add privacy-safe structured audit/debug logging to the
passwordless-user branch in the authentication flow containing the
`usr.password` check. Follow the project’s existing logging conventions, record
that SSO/OIDC/OAuth fallback was used without including the password or raw
email address, and preserve the current password-hash behavior.
---
Nitpick comments:
In `@admin/server/services.py`:
- Around line 120-123: Add focused regression coverage for the password-update
logic around the usr.password check: verify users with usr.password set to None
update successfully, and users with an existing matching hash return "Same
password, no need to update!" without persisting a change. Reuse the existing
service and test fixtures/helpers rather than broadening the test scope.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 061c84de-4aeb-4cd2-89ce-aebe4d1d8cef
📒 Files selected for processing (1)
admin/server/services.py
| # SSO-provisioned users (OIDC/OAuth) have no local password (usr.password is None): | ||
| # skip the equality check, which would otherwise crash inside werkzeug's split(). | ||
| if usr.password and check_password_hash(usr.password, psw): |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add privacy-safe logging for the new passwordless-user path.
This newly enabled SSO fallback should emit a structured audit/debug event using the project’s existing logging conventions. Do not log passwords or raw email addresses.
As per coding guidelines, **/*.py: Add logging for new flows.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@admin/server/services.py` around lines 120 - 122, Add privacy-safe structured
audit/debug logging to the passwordless-user branch in the authentication flow
containing the `usr.password` check. Follow the project’s existing logging
conventions, record that SSO/OIDC/OAuth fallback was used without including the
password or raw email address, and preserve the current password-hash behavior.
Source: Coding guidelines
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16914 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
Setting a password from the admin panel for an SSO-provisioned account (OIDC/OAuth/GitHub) returns a 500 with:
Root cause — SSO-provisioned accounts have no local password, so
usr.passwordisNone(theUser.passwordcolumn isnull=True). InUserMgr.update_user_password(admin/server/services.py), the "same password" optimization calls:werkzeug.security.check_password_hash(None, psw)internally doespwhash.split("$"), which raisesAttributeError: 'NoneType' object has no attribute 'split'→ surfaced as a 500.Repro
oauthin the service config.'NoneType' object has no attribute 'split'.Fix — guard the equality check with
usr.password. A passwordless (SSO) user skips the comparison and goes straight to setting the new password, which is the desired behavior (it gives them a password fallback in addition to SSO).Type of change