Unable to save custom API tool #1152

Closed
opened 2026-02-21 17:30:14 -05:00 by yindo · 5 comments
Owner

Originally created by @bowenliang123 on GitHub (Mar 4, 2024).

Originally assigned to: @Yeuoly on GitHub.

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Pleas do not modify this template :) and fill in all the required fields.

Dify version

main/0.5.7

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  • Create a custom tool, use the default JSON sample of "Weather"
  • Click save button, and then failed
    image
fd9d1056-83a0a335d995ca9c.js:1 Uncaught TypeError: Cannot delete property 'api_key_header' of #<Object>
    at onClick (4168-d9f3874f72da8251.js:1:49527)
    at Object.aS (fd9d1056-83a0a335d995ca9c.js:1:71761)
    at aN (fd9d1056-83a0a335d995ca9c.js:1:71915)
    at fd9d1056-83a0a335d995ca9c.js:1:138576
    at sw (fd9d1056-83a0a335d995ca9c.js:1:138675)
    at sS (fd9d1056-83a0a335d995ca9c.js:1:139089)
    at fd9d1056-83a0a335d995ca9c.js:1:145232
    at oK (fd9d1056-83a0a335d995ca9c.js:1:92812)
    at iL (fd9d1056-83a0a335d995ca9c.js:1:122042)
    at sN (fd9d1056-83a0a335d995ca9c.js:1:140397)

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @bowenliang123 on GitHub (Mar 4, 2024). Originally assigned to: @Yeuoly on GitHub. ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] Pleas do not modify this template :) and fill in all the required fields. ### Dify version main/0.5.7 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce - Create a custom tool, use the default JSON sample of "Weather" - Click save button, and then failed <img width="1499" alt="image" src="https://github.com/langgenius/dify/assets/1935105/2d4c19ca-bfc9-4333-898b-24210860a6f9"> ``` fd9d1056-83a0a335d995ca9c.js:1 Uncaught TypeError: Cannot delete property 'api_key_header' of #<Object> at onClick (4168-d9f3874f72da8251.js:1:49527) at Object.aS (fd9d1056-83a0a335d995ca9c.js:1:71761) at aN (fd9d1056-83a0a335d995ca9c.js:1:71915) at fd9d1056-83a0a335d995ca9c.js:1:138576 at sw (fd9d1056-83a0a335d995ca9c.js:1:138675) at sS (fd9d1056-83a0a335d995ca9c.js:1:139089) at fd9d1056-83a0a335d995ca9c.js:1:145232 at oK (fd9d1056-83a0a335d995ca9c.js:1:92812) at iL (fd9d1056-83a0a335d995ca9c.js:1:122042) at sN (fd9d1056-83a0a335d995ca9c.js:1:140397) ``` ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 17:30:14 -05:00
yindo closed this issue 2026-02-21 17:30:14 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 4, 2024):

Hey there, @bowenliang123! Long time no debug 😄. Good to see you back. Just spotted your issue and I'm diving into the matrix to find out what's up. Hang tight, will get back to you with some insights shortly!

@dosubot[bot] commented on GitHub (Mar 4, 2024): <!-- Greeting --> Hey there, @bowenliang123! Long time no debug 😄. Good to see you back. Just spotted your issue and I'm diving into the matrix to find out what's up. Hang tight, will get back to you with some insights shortly!
Author
Owner

@crazywoola commented on GitHub (Mar 4, 2024):

Link https://github.com/langgenius/dify/pull/2621

@crazywoola commented on GitHub (Mar 4, 2024): Link https://github.com/langgenius/dify/pull/2621
Author
Owner

@dosubot[bot] commented on GitHub (Mar 4, 2024):

Based on the error message and the stack trace you provided, it seems like the issue is related to the deletion of the 'api_key_header' property of an object. This property is used in the process of saving a custom API tool to specify the name of the HTTP header where the API key should be included in requests to the API.

The error message "Uncaught TypeError: Cannot delete property 'api_key_header' of #

@dosubot[bot] commented on GitHub (Mar 4, 2024): <!-- Answer --> Based on the error message and the stack trace you provided, it seems like the issue is related to the deletion of the `'api_key_header'` property of an object. This property is used in the process of saving a custom API tool to specify the name of the HTTP header where the API key should be included in requests to the API. The error message "Uncaught TypeError: Cannot delete property 'api_key_header' of #<Object>" typically occurs when you try to delete a property that doesn't exist on an object, or the property is an inherited property (not an own property of the object), or the property is non-configurable. In JavaScript, you can only delete properties from an object which are configurable. If the property is non-configurable, you'll get a TypeError when you try to delete it. The pull request you mentioned, [PR#2621](https://github.com/langgenius/dify/pull/2621), seems to be related to the issue. However, without more context about the changes made in this pull request, it's hard to say for sure how it's related to the issue you're experiencing. To resolve this issue, you could try the following steps: 1. Check if the `'api_key_header'` property exists on the object before trying to delete it. You can do this by using the `hasOwnProperty` method: ```javascript if (object.hasOwnProperty('api_key_header')) { delete object.api_key_header; } ``` 2. If the `'api_key_header'` property is an inherited property, you'll need to delete it from the object it was inherited from, or change it to be an own property of the object. 3. If the `'api_key_header'` property is non-configurable, you'll need to change it to be configurable before you can delete it. You can do this by using the `Object.defineProperty` method: ```javascript Object.defineProperty(object, 'api_key_header', { configurable: true }); delete object.api_key_header; ``` Please try these steps and let me know if they help resolve the issue. If not, could you provide more context about the changes made in PR#2621 and how they might be related to the issue? This would help me better understand the problem and suggest a more accurate solution. For more information about the `'api_key_header'` property and how it's used in the Dify codebase, you can refer to the [api/core/tools/provider/api_tool_provider.py](https://github.com/langgenius/dify/blob/main/api/core/tools/provider/api_tool_provider.py) file and the [api/fields/api_based_extension_fields.py](https://github.com/langgenius/dify/blob/main/api/fields/api_based_extension_fields.py) file. ## Sources - [api/fields/api_based_extension_fields.py](https://github.com/langgenius/dify/blob/main/api/fields/api_based_extension_fields.py) - [api/core/tools/provider/api_tool_provider.py](https://github.com/langgenius/dify/blob/main/api/core/tools/provider/api_tool_provider.py) <!-- Dosu Comment Footer --> <details open> <summary> #### About Dosu </summary> This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. </details>
Author
Owner

@bowenliang123 commented on GitHub (Mar 4, 2024):

Link #2621

It works fine if #2621 is reverted.
cc @Yeuoly

@bowenliang123 commented on GitHub (Mar 4, 2024): > Link #2621 It works fine if #2621 is reverted. cc @Yeuoly
Author
Owner

@Yeuoly commented on GitHub (Mar 4, 2024):

fixed #2673

@Yeuoly commented on GitHub (Mar 4, 2024): fixed #2673
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#1152