Skip to content

Fix: admin password update crashes for SSO users (500 'NoneType' object has no attribute 'split') - #16914

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
vincentlambert:fix/admin-password-sso-user
Jul 14, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
vincentlambert:fix/admin-password-sso-user

Conversation

@vincentlambert

Copy link
Copy Markdown
Contributor

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:

'NoneType' object has no attribute 'split'

Root cause — SSO-provisioned accounts have no local password, so usr.password is None (the User.password column is null=True). In UserMgr.update_user_password (admin/server/services.py), the "same password" optimization calls:

if check_password_hash(usr.password, psw):

werkzeug.security.check_password_hash(None, psw) internally does pwhash.split("$"), which raises AttributeError: 'NoneType' object has no attribute 'split' → surfaced as a 500.

Repro

  1. Configure an SSO channel (OIDC/OAuth) under oauth in the service config.
  2. Log in once via SSO so the account is auto-provisioned (created without a local password).
  3. In the admin panel, set/change that user's password.
  4. → 500 '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

  • Bug Fix (non-breaking change which fixes an issue)

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]>
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

update_user_password now guards password-hash comparison for users without local passwords, preventing failures for SSO-provisioned accounts while preserving existing update behavior.

Changes

Password update handling

Layer / File(s) Summary
Guard password hash comparison
admin/server/services.py
The equality check now runs only when usr.password exists, preserving same-password detection for local-password users.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: wangq8

Poem

A rabbit checks the password gate,
No hash? No crash awaits.
SSO friends hop safely through,
Local checks still do what they do.
Fresh updates bloom anew.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main fix: preventing admin password updates from crashing for SSO users.
Description check ✅ Passed The description covers the problem, root cause, repro steps, and fix, which satisfies the repository's summary requirement.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
admin/server/services.py (1)

120-123: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression coverage for both password states.

Please add a focused test proving that usr.password is None updates 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

📥 Commits

Reviewing files that changed from the base of the PR and between 55d5879 and 0c5d290.

📒 Files selected for processing (1)
  • admin/server/services.py

Comment thread admin/server/services.py
Comment on lines +120 to +122
# 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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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

@JinHai-CN JinHai-CN added the ci Continue Integration label Jul 14, 2026
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (55d5879) to head (0c5d290).
⚠️ Report is 3 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit 5cf95d2 into infiniflow:main Jul 14, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants