Repository navigation
Fix user setting API to use allowlist for updatable fields - #14863
Conversation
|
Caution Review failedFailed to post review comments 📝 WalkthroughWalkthroughPATCH /users/me now uses an explicit allowlist (nickname, avatar, language, color_schema, timezone) to build the update payload; unsupported non-password fields are collected and logged as a warning. Tests were updated to capture and assert the emitted warning and excluded fields; docs add a sandbox settings screenshot and a Provider options subsection. ChangesUser Settings Update Security Fix
Docs: Sandbox Quickstart
sequenceDiagram
participant Client
participant PATCH_users_me as UserAPI
participant UserService
participant Database
participant Logger
Client->>PATCH_users_me: PATCH /users/me with request body
PATCH_users_me->>PATCH_users_me: filter request fields using allowlist
PATCH_users_me->>UserService: update_by_id(user_id, filtered_update_dict)
UserService->>Database: persist allowed fields
PATCH_users_me->>Logger: warning(user_id, ignored_fields)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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
🤖 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 `@api/apps/restful_apis/user_api.py`:
- Around line 336-339: The loop building update_dict drops unexpected keys
silently; modify the code around ALLOWED_USER_UPDATE_FIELDS / request_data /
update_dict to collect any request_data keys that are not in
ALLOWED_USER_UPDATE_FIELDS and emit an audit log (e.g., using the existing
logger or current_app.logger) containing the ignored field names (not values)
and context (user id or request id if available) at info/warning level so client
misuse or abuse is visible; keep the existing behavior of not including values
and still only adding allowlisted keys to update_dict.
🪄 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: e46a6854-b47c-4b82-a087-24093d601e64
📒 Files selected for processing (1)
api/apps/restful_apis/user_api.py
|
Hi, @JinHai-CN |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14863 +/- ##
=======================================
Coverage 93.12% 93.12%
=======================================
Files 10 10
Lines 713 713
Branches 116 116
=======================================
Hits 664 664
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Appreciations! CI failure. |
### What problem does this PR solve? This PR improves the connector dashboard task management experience and adds better visibility into connector execution logs. ### Overview: <img width="700" alt="image" src="https://github.com/user-attachments/assets/0e643433-878e-44f7-9b98-5b8217be5e19" /> ### 1. Support hot switching during agent runs and complete log updates Supports switching providers during an agent run, for example: local provider -> self-managed provider -> local provider <img width="700" alt="image" src="https://github.com/user-attachments/assets/bc52fc77-e44b-415d-b5c9-0e035f9a2cee" /> ### 2. Support SSH provider <img width="700" alt="image" src="https://github.com/user-attachments/assets/d3039f7a-df71-4e07-9120-5748f36ece64" /> ### 3. Support local provider <img width="700" alt="image" src="https://github.com/user-attachments/assets/d5d1b170-8d45-4da4-afa3-957bb69557b8" /> ### 4. Expose self-managed deployment defaults Self-managed deployment defaults are now visible to users and can be customized in `docker/.env`. These values are kept as deployment defaults because changes require a hard restart to take effect. <img width="700" alt="image" src="https://github.com/user-attachments/assets/05923610-e083-4f1c-bef9-4db90ad131b8" /> ### Type of change - [x] New Feature (non-breaking change which adds functionality)
…reak RAPTOR (infiniflow#14998) ### What problem does this PR solve? Fixes infiniflow#14997. RAPTOR builds on the Infinity backend have been broken since v0.25.2 introduced the `extra` field in code (`rag/svr/task_executor.py:1011`) without declaring it in `conf/infinity_mapping.json`. Every RAPTOR job fails with: ``` infinity.common.InfinityException: (3013, 'Fail to bind the expression: extra@src/planner/expression_binder_impl.cpp:99') ``` The auto-migration in `common/doc_store/infinity_conn_base.py:_migrate_db()` adds any columns it finds in the mapping JSON to existing tables — so the only thing standing between users and a working RAPTOR build is that one missing declaration. OceanBase, ES, and OpenSearch were unaffected because they store `extra` as a native JSON type; only Infinity (which has a strict `varchar`/`integer`/`float` schema) needed the addition. ### The fix Two-part change: 1. **`conf/infinity_mapping.json`**: declare `"extra": {"type": "varchar", "default": ""}`. On next startup, `_migrate_db()` adds the column to all existing chunk tables — no manual DDL needed for upgrading installations. 2. **`rag/utils/infinity_conn.py` `insert()`**: serialize the `extra` dict to a JSON string at write time, since Infinity's `varchar` can't store a Python dict directly. Modelled on the existing `chunk_data` handling a few lines above. The read path (`rag/utils/raptor_utils.py:_as_extra_dict`) already normalises both dict and JSON-string inputs, so no read-side change is needed. Other backends are untouched — `task_executor.py` still writes the dict, and the OceanBase/ES/OpenSearch insert paths handle dicts natively. ### Verification Tested on a v0.25.4 deployment with the Infinity backend by applying the same two changes via mounted-volume override: - Confirmed `_migrate_db()` adds the `extra` column to all pre-existing chunk tables on startup (column visible via Infinity's `show_columns()`). - Triggered RAPTOR builds on four datasets (~21k chunks total) via `POST /api/v1/datasets/<id>/index?type=raptor`. - All four progressed past the previously-failing `get_raptor_chunk_methods()` call into actual entity-extraction and clustering work without the (3013) error. - GraphRAG builds (which can trigger the same path indirectly via `task_executor.py:857`) also progressed cleanly. ### Type of change - [X] Bug Fix (non-breaking change which fixes an issue)
|
Hi, @KevinHuSh |
What problem does this PR solve?
The
PATCH /users/meendpoint uses a denylist to filter out sensitive fields, which means any new or unexpected fields in the request body are accepted and written to the database by default. This allows users to potentially overwrite protected fields that weren't explicitly blocked.This PR replaces the denylist with an allowlist (
nickname,avatar,language,color_schema,timezone), so only explicitly permitted fields can be updated. This is a safer default — new fields are denied unless intentionally added to the allowlist.Fixes #14861
Type of change