mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-21 17:45:23 -04:00
Incorrect Dictionary Key Access Causing AttributeError in _upload_file_to_tongyi Method #281
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @cmlibo on GitHub (May 15, 2025).
Self Checks
Dify version
1.3.1
Plugin version
0.0.25
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
Description:
The _upload_file_to_tongyi method incorrectly accesses the dashscope_api_key value using dot notation (credentials.dashscope_api_key) instead of dictionary key syntax, resulting in an AttributeError when credentials is passed as a dict.
Steps to Reproduce:
Call the _upload_file_to_tongyi method with credentials as a Python dictionary (e.g., {"dashscope_api_key": "YOUR_KEY"}).
The code will fail at this line:
client = OpenAI(
api_key=credentials.dashscope_api_key, # ❌ Incorrect access
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)
Error:
AttributeError: 'dict' object has no attribute 'dashscope_api_key'
Expected Behavior:
The code should access the dashscope_api_key value using dictionary key syntax (credentials["dashscope_api_key"]).
Suggested Fix:
Replace credentials.dashscope_api_key with credentials["dashscope_api_key"] in the _upload_file_to_tongyi method:
client = OpenAI( api_key=credentials["dashscope_api_key"], # ✅ Correct access base_url="https://dashscope.aliyuncs.com/compatible-mode/v1", )✔️ Error log
[tongyi] Error: PluginInvokeError: {"args":{"description":"[models] Error: 'dict' object has no attribute 'dashscope_api_key'"},"error_type":"InvokeError","message":"[models] Error: 'dict' object has no attribute 'dashscope_api_key'"}
@aaditiiiii1 commented on GitHub (May 20, 2025):
Hi @cmlibo ,
I'd like to take this issue and submit a fix.
Bug Summary
The
_upload_file_to_tongyimethod currently accesses the API key like this:When credentials is a dictionary, this causes:
AttributeError: 'dict' object has no attribute 'dashscope_api_key'
Summary of Planned Changes:
I will modify the code to correctly use dictionary key access:
This fix will be made in the following file:
models/tongyi/models/llm/llm.py
Attaching an image for the changes I propose.
Please assign this issue to me.
Let me know if there’s anything else I should consider or if I’ve misunderstood the scope. Thank you!
@dosubot[bot] commented on GitHub (Aug 18, 2025):
Hi, @cmlibo. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.
Issue Summary:
dashscope_api_keyon a dictionary in the_upload_file_to_tongyimethod.credentials.dashscope_api_keytocredentials["dashscope_api_key"].models/tongyi/models/llm/llm.py.Next Steps:
Thank you for your understanding and contribution!