tool-plugin secret-input display unexpected
Self Checks
- [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [x] I have searched for existing issues search for existing issues, including closed ones.
- [x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [x] Please do not modify this template :) and fill in all the required fields.
Dify version
1.1.1
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
I'm working on a tool-plugin development, when I set a parameter to a specific input element with secret-input type, unfortunately the front end doesn't show * marked the content.
please kindly help.
./tools/connector.yaml
parameters:
- name: mysql_password
type: secret-input
required: true
label:
en_US: MySQL Password
zh_Hans: MySQL 密码
human_description:
en_US: Please input your MySQL password
zh_Hans: 请输入你的 MySQL 密码
form: form
✔️ Expected Behavior
the password section should be covered with *
❌ Actual Behavior
To address the issue where the secret-input type is not displaying as expected (i.e., not masking the input with asterisks), ensure that the frontend component responsible for rendering the input fields is correctly configured. The secret-input type should be rendered using an Input component with the type attribute set to 'password'. This is how the Dify frontend typically handles secret-input types:
<Input
type={type === 'secret' ? 'password' : 'text'}
id={variable}
name={variable}
value={fieldValue}
onChange={val => handleFormChange(variable, val.target.value)}
required={required}
className={cn(inputClassName)}
/>
Make sure that the type in your form schema is correctly set to 'secret' so that the input field is rendered as a password field, which will automatically mask the input content [1]. Additionally, verify that your YAML configuration is correctly set up with type: secret-input for the mysql_password parameter, as you've shown in your example [2]. If the issue persists, there might be a problem with how the frontend is interpreting the form schema or rendering the component.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
To address the issue where the
secret-inputtype is not displaying as expected (i.e., not masking the input with asterisks), ensure that the frontend component responsible for rendering the input fields is correctly configured. Thesecret-inputtype should be rendered using anInputcomponent with thetypeattribute set to'password'. This is how the Dify frontend typically handlessecret-inputtypes:<Input type={type === 'secret' ? 'password' : 'text'} id={variable} name={variable} value={fieldValue} onChange={val => handleFormChange(variable, val.target.value)} required={required} className={cn(inputClassName)} /> Make sure that the
typein your form schema is correctly set to'secret'so that the input field is rendered as a password field, which will automatically mask the input content [1]. Additionally, verify that your YAML configuration is correctly set up withtype: secret-inputfor themysql_passwordparameter, as you've shown in your example [2]. If the issue persists, there might be a problem with how the frontend is interpreting the form schema or rendering the component.To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
100% sure the correctly set up with type: secret-input for the mysql_password parameter. And please guide my further for how to adjust the type in the form schema set to 'secret' when i'm creating a tool-plugin.
Still have same appearance. @dosubot
To adjust the type in the form schema to 'secret' when creating a tool-plugin, ensure that the ToolParameter is initialized with ToolParameterType.SECRET_INPUT. Since you have already set up the mysql_password parameter with type: secret-input, you can create a ToolParameter with the type set to SECRET_INPUT like this:
from tool_entities import ToolParameter, ToolParameterType
# Example of creating a ToolParameter with type 'secret'
mysql_password_parameter = ToolParameter.get_simple_instance(
name="mysql_password",
llm_description="The password for MySQL connection",
typ=ToolParameterType.SECRET_INPUT,
required=True
)
This code snippet ensures that the ToolParameter is correctly set to SECRET_INPUT, which corresponds to the 'secret' type in the form schema [1].
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
I also encountered this problem, this is a front-end program BUG, need to modify a tsx file。 file path:
app\components\header\account-setting\model-provider-page\model-modal\Form.tsx
line 170.
type={formSchema.type === FormTypeEnum.textNumber ? 'number' : 'text'}
to
type={formSchema.type === FormTypeEnum.textNumber ? 'number' : (formSchema.type === FormTypeEnum.secretInput ? 'password' : 'text')}
Hi, @bionexit. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.
Issue Summary:
- The issue involves a bug with the
secret-inputtype parameter not displaying masked content. - You reported the issue, and I suggested ensuring the frontend component renders the input field as a password type.
- @zxhxp confirmed the issue and identified a specific line in a TypeScript file that needed modification.
- The problem was related to frontend rendering and required code adjustments.
- The issue has been resolved by configuring the frontend component and modifying the TypeScript file.
Next Steps:
- Please confirm if this issue is still relevant to the latest version of the Dify repository by commenting on this issue.
- If there is no further activity, the issue will be automatically closed in 15 days.
Thank you for your understanding and contribution!