Skip to content

refactor: inject current user id in stop message endpoints#36925

Merged
asukaminato0721 merged 7 commits into
langgenius:mainfrom
likalikali:refactor/inject-current-user-id
Jun 2, 2026
Merged

refactor: inject current user id in stop message endpoints#36925
asukaminato0721 merged 7 commits into
langgenius:mainfrom
likalikali:refactor/inject-current-user-id

Conversation

@likalikali
Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md)
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Refactor console stop-message endpoints to inject the current account id with with_current_user_id.

This PR replaces direct current_user.id usage in stop-message endpoints where only the user id is needed. Handlers that still require the full Account object are kept unchanged.

Fixes #36585

Screenshots

Not applicable. This is a backend refactor and does not change the UI.

Checklist

  • This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs)
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Test

Not run locally. uv sync --dev fails on Windows because clickzetta-connector-python==0.8.104 cannot be resolved through dify-vdb-clickzetta.

@likalikali likalikali requested a review from QuantumGhost as a code owner June 2, 2026 04:21
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. refactor labels Jun 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 46.02% 46.03% +0.01%
Strict coverage 45.52% 45.52% +0.01%
Typed symbols 24,986 24,990 +4
Untyped symbols 29,631 29,629 -2
Modules 2790 2790 0

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors console stop-message endpoints to inject the authenticated user’s ID via @with_current_user_id, avoiding direct dependency on current_user where only the ID is needed.

Changes:

  • Added @with_current_user_id to stop endpoints and updated handler signatures to accept current_user_id: str.
  • Replaced user_id=current_user.id with user_id=current_user_id in stop-task calls.
  • Removed current_user type assertions in the explore stop endpoints (and one of the debugger stop endpoints).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
api/controllers/console/explore/completion.py Uses @with_current_user_id for installed-app stop endpoints and passes current_user_id into AppTaskService.stop_task.
api/controllers/console/app/completion.py Applies @with_current_user_id to debugger stop endpoints and switches stop-task calls to use the injected user id.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread api/controllers/console/app/completion.py
Comment thread api/controllers/console/app/completion.py
Comment thread api/controllers/console/app/completion.py Outdated
@asukaminato0721 asukaminato0721 self-requested a review June 2, 2026 04:31
asukaminato0721
asukaminato0721 previously approved these changes Jun 2, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 2, 2026
@asukaminato0721
Copy link
Copy Markdown
Contributor

fix test, you can check how other pr do.

change the signature.

auto-merge was automatically disabled June 2, 2026 05:08

Head branch was pushed to by a user without write access

@likalikali likalikali requested a review from laipz8200 as a code owner June 2, 2026 05:08
@likalikali
Copy link
Copy Markdown
Contributor Author

fix test, you can check how other pr do.

change the signature.

Updated the stop endpoint tests to pass current_user_id explicitly after unwrapping the decorated handlers.

@asukaminato0721 asukaminato0721 enabled auto-merge June 2, 2026 05:37
Comment thread api/tests/unit_tests/controllers/console/explore/test_completion.py Outdated
Comment thread api/tests/unit_tests/controllers/console/explore/test_completion.py Outdated
Comment thread api/tests/unit_tests/controllers/console/explore/test_completion.py Outdated
Comment thread api/tests/unit_tests/controllers/console/explore/test_completion.py Outdated
Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
@asukaminato0721 asukaminato0721 added this pull request to the merge queue Jun 2, 2026
Merged via the queue into langgenius:main with commit 7056985 Jun 2, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dep inject current user id

3 participants