The length of the tag does not match the actual error reported #5504

Closed
opened 2026-02-21 18:11:20 -05:00 by yindo · 1 comment
Owner

Originally created by @hwzhuhao on GitHub (Sep 10, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • 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).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.7.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

1.add tag with 1testtesttesttesttesttesttesttesttesttest for workflow.

✔️ Expected Behavior

create tag successful

Actual Behavior

tag

Originally created by @hwzhuhao on GitHub (Sep 10, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [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] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.7.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1.add tag with 1testtesttesttesttesttesttesttesttesttest for workflow. ### ✔️ Expected Behavior create tag successful ### ❌ Actual Behavior ![tag](https://github.com/user-attachments/assets/2a665390-565b-437e-95ef-cfafdfa2d58a)
yindo added the 🐞 bug label 2026-02-21 18:11:20 -05:00
yindo closed this issue 2026-02-21 18:11:20 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 10, 2024):

I found a similar unsolved discussion that might be relevant to your issue: Why this not work, which was last updated on September 5, 2024 [1].

Regarding the tag length validation, it is implemented in two places in the codebase:

  1. In the _validate_name function within the api/controllers/console/tag/tags.py file. This function checks if the tag name is between 1 to 50 characters.
def _validate_name(name):
    if not name or len(name) < 1 or len(name) > 50:
        raise ValueError("Name must be between 1 to 50 characters.")
    return name
  1. In the TagInput component within the web/app/components/base/tag-input/index.tsx file. This component checks if the tag length exceeds 20 characters and displays an error message if it does.
const handleKeyDown = (e: KeyboardEvent) => {
  if (isSpecialMode && e.key === 'Enter')
    setValue(`${value}↵`)

  if (e.key === customizedConfirmKey) {
    if (isSpecialMode)
      e.preventDefault()

    const valueTrimmed = value.trim()
    if (!valueTrimmed || (items.find(item => item === valueTrimmed)))
      return

    if (valueTrimmed.length > 20) {
      notify({ type: 'error', message: t('datasetDocuments.segment.keywordError') })
      return
    }

    onChange([...items, valueTrimmed])
    setTimeout(() => {
      setValue('')
    })
  }
}

It seems there might be a discrepancy between the backend and frontend validations. The backend allows up to 50 characters, while the frontend restricts it to 20 characters [2][3].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 10, 2024): <!-- Answer --> I found a similar unsolved discussion that might be relevant to your issue: [Why this not work](https://github.com/langgenius/dify/discussions/8006), which was last updated on September 5, 2024 <sup>[[1]](https://github.com/langgenius/dify/discussions/8006)</sup>. Regarding the tag length validation, it is implemented in two places in the codebase: 1. In the `_validate_name` function within the `api/controllers/console/tag/tags.py` file. This function checks if the tag name is between 1 to 50 characters. ```python def _validate_name(name): if not name or len(name) < 1 or len(name) > 50: raise ValueError("Name must be between 1 to 50 characters.") return name ``` 2. In the `TagInput` component within the `web/app/components/base/tag-input/index.tsx` file. This component checks if the tag length exceeds 20 characters and displays an error message if it does. ```tsx const handleKeyDown = (e: KeyboardEvent) => { if (isSpecialMode && e.key === 'Enter') setValue(`${value}↵`) if (e.key === customizedConfirmKey) { if (isSpecialMode) e.preventDefault() const valueTrimmed = value.trim() if (!valueTrimmed || (items.find(item => item === valueTrimmed))) return if (valueTrimmed.length > 20) { notify({ type: 'error', message: t('datasetDocuments.segment.keywordError') }) return } onChange([...items, valueTrimmed]) setTimeout(() => { setValue('') }) } } ``` It seems there might be a discrepancy between the backend and frontend validations. The backend allows up to 50 characters, while the frontend restricts it to 20 characters <sup>[[2]](https://github.com/langgenius/dify/blob/main/api/controllers/console/tag/tags.py)</sup><sup>[[3]](https://github.com/langgenius/dify/blob/main/web/app/components/base/tag-input/index.tsx)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5504