Skip to content

PY: fix admin error - #16827

Merged
JinHai-CN merged 2 commits into
infiniflow:mainfrom
JinHai-CN:fix537
Jul 11, 2026
Merged

PY: fix admin error#16827
JinHai-CN merged 2 commits into
infiniflow:mainfrom
JinHai-CN:fix537

Conversation

@JinHai-CN

Copy link
Copy Markdown
Contributor

Summary

Sync code from EE

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The admin client now requires a newer beartype version. Admin login documentation and local naming were clarified, and administrators can no longer change their own activation status.

Changes

Admin authentication and account controls

Layer / File(s) Summary
Login clarity and self-status protection
admin/server/auth.py, admin/server/routes.py
The login password documentation specifies RSA-encrypted, base64-encoded input, the decrypted variable is renamed, and self-targeted activation-status changes now return HTTP 409.

Admin client dependency baseline

Layer / File(s) Summary
Beartype version requirement
admin/client/pyproject.toml
The minimum beartype version is raised to 0.22.9 while retaining the <1.0.0 upper bound.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

I’m a bunny guarding the admin door,
Clearer passwords, safer status toggles galore.
Beartype hops to a newer release,
While self-edits stop for account peace.
Nibble, verify, and deploy with ease!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only says 'Sync code from EE' and does not explain the change, purpose, or background required by the template. Expand the Summary section with the problem being fixed, why the EE sync was needed, and the user-facing impact.
Title check ❓ Inconclusive The title is related to the admin changes, but it is too generic to clearly summarize the main fix. Rename it to mention the specific admin fix, such as blocking self-activation changes or the auth/password update.
✅ Passed checks (3 passed)
Check name Status Explanation
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.

@JinHai-CN JinHai-CN added the ci Continue Integration label Jul 11, 2026
@JinHai-CN
JinHai-CN marked this pull request as ready for review July 11, 2026 03:10
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jul 11, 2026

@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: 2

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

156-157: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Log the new self-status rejection path.

This newly added flow currently returns without logging. Add a structured warning/info log containing the actor and target identifiers according to the repository’s Python logging guideline, while avoiding unnecessary sensitive data.

🤖 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/routes.py` around lines 156 - 157, The self-status rejection in
the current-user status update handler returns without an audit log. Add a
structured warning or info log immediately before the error response, including
the actor and target identifiers using the repository’s Python logging
conventions while excluding unnecessary sensitive data.

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/client/pyproject.toml`:
- Line 11: Regenerate admin/client/uv.lock with `uv lock` so the beartype
resolution and metadata satisfy the updated constraint in pyproject.toml, then
verify the lockfile reflects a version at least 0.22.9.

In `@admin/server/routes.py`:
- Around line 156-157: Update error_response to accept a separate HTTP-status
parameter defaulting to its existing status, then use that parameter when
constructing the response. In the current-user check in the relevant route, call
error_response with both the JSON code and HTTP status set to 409 so the client
receives an actual HTTP 409 response.

---

Nitpick comments:
In `@admin/server/routes.py`:
- Around line 156-157: The self-status rejection in the current-user status
update handler returns without an audit log. Add a structured warning or info
log immediately before the error response, including the actor and target
identifiers using the repository’s Python logging conventions while excluding
unnecessary sensitive data.
🪄 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: 44f9fb0a-d24e-4d29-b891-4c8496aa4892

📥 Commits

Reviewing files that changed from the base of the PR and between 4060cd1 and abbb854.

📒 Files selected for processing (3)
  • admin/client/pyproject.toml
  • admin/server/auth.py
  • admin/server/routes.py

dependencies = [
"requests>=2.30.0,<3.0.0",
"beartype>=0.20.0,<1.0.0",
"beartype>=0.22.9,<1.0.0",

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚖️ Poor tradeoff

Lockfile is out of sync with the new beartype constraint.

admin/client/uv.lock currently pins beartype at 0.22.6, which no longer satisfies the new >=0.22.9 floor. The lockfile must be regenerated (uv lock) so the resolved version and metadata reflect the tightened requirement. Otherwise CI or local installs that rely on the lockfile will either fail or install a version that violates the declared constraint.

As per coding guidelines, "Run the narrowest relevant test, lint, or build command after a change." — regenerating the lockfile is the equivalent build step here.

🔧 Regenerate the lockfile
cd admin/client && uv lock
🤖 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/client/pyproject.toml` at line 11, Regenerate admin/client/uv.lock with
`uv lock` so the beartype resolution and metadata satisfy the updated constraint
in pyproject.toml, then verify the lockfile reflects a version at least 0.22.9.

Comment thread admin/server/routes.py
Comment on lines +156 to +157
if current_user.email == username:
return error_response(f"can't alter current user status: {username}", 409)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Return an actual HTTP 409 response.

error_response(..., 409) only sets the JSON code; admin/server/responses.py:23-24 always returns HTTP 400. This violates the intended conflict response and can break clients branching on the HTTP status.

Add a separate HTTP-status parameter to error_response while preserving its existing default, then call it with both body code and HTTP status set to 409.

🤖 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/routes.py` around lines 156 - 157, Update error_response to
accept a separate HTTP-status parameter defaulting to its existing status, then
use that parameter when constructing the response. In the current-user check in
the relevant route, call error_response with both the JSON code and HTTP status
set to 409 so the client receives an actual HTTP 409 response.

@JinHai-CN
JinHai-CN marked this pull request as draft July 11, 2026 06:13
@JinHai-CN
JinHai-CN marked this pull request as ready for review July 11, 2026 06:13
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (4060cd1) to head (abbb854).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16827      +/-   ##
==========================================
- Coverage   94.56%   93.16%   -1.40%     
==========================================
  Files          10       10              
  Lines         717      717              
  Branches      118      118              
==========================================
- Hits          678      668      -10     
- Misses         25       29       +4     
- Partials       14       20       +6     

☔ 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 e6e99b8 into infiniflow:main Jul 11, 2026
10 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant