Repository navigation
fix: [AI Agent] The same workflow functions correctly during backend debugging; however, when accessed via a web link, images fail to load during conversation, and certain nodes are missing from the execution details. #7718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -186,18 +186,14 @@ def _upload_tool_file(self, file, workflow_params): | |
| def _upload_application_file(self, file, workflow_params): | ||
| application_id = workflow_params.get("application_id") | ||
| chat_id = workflow_params.get("chat_id") | ||
| debug = workflow_params.get("debug", False) | ||
| meta = { | ||
| "debug": debug, | ||
| "chat_id": chat_id, | ||
| "application_id": application_id, | ||
| } | ||
| chat_user_id = workflow_params.get("chat_user_id") | ||
| meta = {"chat_id": chat_id, "application_id": application_id, "user_id": chat_user_id} | ||
| file_url = FileSerializer( | ||
| data={ | ||
| "file": file, | ||
| "meta": meta, | ||
| "source_id": application_id, | ||
| "source_type": FileSourceType.APPLICATION.value, | ||
| "source_id": chat_id, | ||
| "source_type": FileSourceType.CHAT.value, | ||
| } | ||
| ).upload() | ||
| return file_url | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issues & Suggestions
Overall: logic looks intentional (shifting file ownership from application-level to chat-level + user attribution), but items 1–4 deserve verification before merging. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -456,7 +456,7 @@ def post(self, request: Request): | |
| version, get_key = Cache_Version.CHAT_USER_TOKEN.value | ||
| auth = request.META.get("HTTP_AUTHORIZATION") | ||
| cache.delete(get_key(token=auth), version=version) | ||
| return result.success(True) | ||
| return clear_file_auth_cookie(result.success(True), request.query_params.get("accessToken")) | ||
| return result.error(_("Failed to change password")) | ||
|
|
||
|
|
||
|
|
@@ -481,6 +481,20 @@ def get(self, request: Request): | |
| return result.success(ChatUserProfileSerializer().profile(request.user.profile)) | ||
|
|
||
|
|
||
| FILE_AUTH_COOKIE = "mk_file_auth" | ||
|
|
||
|
|
||
| def get_chat_user_cookie_path(access_token): | ||
| """对话用户登录时写入文件凭证 cookie 的路径;退出登录时按同一路径删除。""" | ||
| return f"/chat/{access_token + '/' if access_token else ''}" | ||
|
|
||
|
|
||
| def clear_file_auth_cookie(response: HttpResponse, access_token): | ||
| """删除对话用户登录写入的文件凭证 cookie;该 cookie 为 HttpOnly,前端无法自行清除。""" | ||
| response.delete_cookie(FILE_AUTH_COOKIE, path=get_chat_user_cookie_path(access_token), samesite="Lax") | ||
| return response | ||
|
|
||
|
|
||
| class BaseAuthView(APIView): | ||
| def create_token_and_cache(self, user, access_token, operate): | ||
| application_id = None | ||
|
|
@@ -522,7 +536,7 @@ def create_token_and_cache(self, user, access_token, operate): | |
| def generate(self, request, token: str, response: HttpResponse, path: str = "/chat"): | ||
| secure = request.is_secure() | ||
| response.set_cookie( | ||
| "mk_file_auth", | ||
| FILE_AUTH_COOKIE, | ||
| value=token, | ||
| max_age=7 * 24 * 3600, | ||
| path=path, | ||
|
|
@@ -550,7 +564,7 @@ def post(self, request: Request): | |
| user.source = "LOCAL" | ||
| token = self.create_token_and_cache(user, access_token, Operate.LOCAL) | ||
| response = result.success({"token": token}) | ||
| return self.generate(request, token, response, path=f"/chat/{access_token + '/' if access_token else ''}") | ||
| return self.generate(request, token, response, path=get_chat_user_cookie_path(access_token)) | ||
|
|
||
|
|
||
| class Logout(APIView): | ||
|
|
@@ -569,4 +583,4 @@ def post(self, request: Request): | |
| version, get_key = Cache_Version.CHAT_USER_TOKEN.value | ||
| auth = request.META.get("HTTP_AUTHORIZATION") | ||
| cache.delete(get_key(token=auth[7:]), version=version) | ||
| return result.success(True) | ||
| return clear_file_auth_cookie(result.success(True), request.query_params.get("accessToken")) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can only review the shown diff/surrounding lines, so I’m assuming the missing imports/settings are already correct. Potential bugs / correctness issues
Compatibility / implementation notes
Suggested cleanup / optimization
SummaryThe main functional risk is that the cookie is only cleared if |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
1. Potential issues (bugs)
source_id/source_typesemantics silently: The file is now attributed to the chat rather than the application. If any existing logic queries files bysource_id = application_idwithFileSourceType.APPLICATION(e.g., cleanup, permissions, display), it will break or lose access to previously-uploaded files. Verify all consumers before merging.debugwas removed from meta. If downstream code readsmeta["debug"](e.g., to skip persistence or apply debug behavior), this is a regression. Confirm it's now handled elsewhere; if not, keep it.chat_id,application_id, orchat_user_idis absent fromworkflow_params,Nonegets written into metadata/source_id silently. Add validation:chat_user_idbut stored asuser_id. Fine, but document it, since key mismatch is a common bug source.2. Minor style/robustness
.get()defaults for consistency:workflow_params.get("chat_user_id", "")if empty strings are preferable toNonein storage._upload_tool_file(which presumably should get the sameuser_idtreatment — check for symmetry).3. Optimization suggestions
Summary: No syntax problems, but the semantic change of
source_id/source_typeand removal ofdebugare behavior changes that must be verified against all consumers of this metadata.