Skip to content
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

value too long for type character varying(40) #13921

Open
5 tasks done
zzyyll2 opened this issue Feb 18, 2025 · 14 comments
Open
5 tasks done

value too long for type character varying(40) #13921

zzyyll2 opened this issue Feb 18, 2025 · 14 comments
Labels
🐞 bug Something isn't working

Comments

@zzyyll2
Copy link

zzyyll2 commented Feb 18, 2025

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

1.0.0-beta.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

my settings:
Image

Image

error log:
[SQL: INSERT INTO dataset_collection_bindings (provider_name, model_name, type, collection_name) VALUES (%(provider_name)s, %(model_name)s, %(type)s, %(collection_name)s) RETURNING dataset_collection_bindings.id, dataset_collection_bindings.created_at]
[parameters: {'provider_name': 'langgenius/openai_api_compatible/openai_api_compatible', 'model_name': 'text-embedding-3-small', 'type': 'dataset', 'collection_name': 'Vector_index_383d24b8_fe9f_4984_854f_78fc3be7e218_Node'}]
(Background on this error at: https://sqlalche.me/e/20/9h9h)

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

@zzyyll2
Copy link
Author

zzyyll2 commented Feb 18, 2025

perhaps provider_name's value 'langgenius/openai_api_compatible/openai_api_compatible', it's length is 51 > 40
why the value is 'langgenius/openai_api_compatible/openai_api_compatible' not 'openai_api_compatible'?

@dosubot dosubot bot added the 🐞 bug Something isn't working label Feb 18, 2025
Copy link

dosubot bot commented Feb 18, 2025

Hey @zzyyll2! I'm here to help you with any bugs, questions, or contributions you have. Let's solve this together!

The error "value too long for type character varying(40)" is occurring because the provider_name column in the dataset_collection_bindings table is defined with a maximum length of 40 characters. The value 'langgenius/openai_api_compatible/openai_api_compatible' exceeds this limit with a length of 51 characters [1].

To resolve this, you should ensure that the database migration to increase the column length has been applied. There is a migration script that alters the provider_name column in the embeddings table to allow for longer values, but it seems this change might not have been applied to the dataset_collection_bindings table. You should check if there is a similar migration for this table or consider creating one to increase the column length to accommodate longer values [2].

If the migration has not been applied, follow the process for applying database migrations in the Dify platform. If you are using Docker, ensure the MIGRATION_ENABLED environment variable is set to true, and restart the services. If running from source, manually run flask db upgrade in the api directory [3].

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

@zzyyll2
Copy link
Author

zzyyll2 commented Feb 18, 2025

@dosu I have newly installed it, not upgraded from an old version, do I also need to perform these operations? If so, please indicate this in the document. Thank you.

Copy link

dosubot bot commented Feb 18, 2025

Yes, even with a new installation of the Dify platform, you need to perform database migration operations. This is necessary to ensure that your database schema is up-to-date with the latest version of the platform. The documentation should indeed indicate this requirement to guide users through the installation process. You can perform the migration by running the flask db upgrade command in the appropriate directory [1][2].

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

@zzyyll2
Copy link
Author

zzyyll2 commented Feb 18, 2025

@dosu I found MIGRATION_ENABLED environment variable is set to true default.

Image

Copy link

dosubot bot commented Feb 18, 2025

That's great to hear! Since the MIGRATION_ENABLED environment variable is set to true by default, the migrations should run automatically when you start the application. If you're still encountering the issue, try restarting your Docker containers to ensure the migrations are applied. If the problem persists, you might want to manually run flask db upgrade in the API directory to ensure all migrations are applied correctly. Let me know if you need further assistance!

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

@zzyyll2
Copy link
Author

zzyyll2 commented Feb 18, 2025

@dosu
I have reviewed the code, branch is 1.0.0-beta.1,i search dataset_collection_bindings, result below picture:

Image

There is not a migration script that alters the provider_name column in the embeddings table to allow for longer values.

look the code:

Image

thanks.

Copy link

dosubot bot commented Feb 18, 2025

Hey @zzyyll2! It looks like you're diving deep into the migration scripts and database schema. While I can help with technical questions and bug fixes, I'm not equipped to review or analyze code directly. If you think I should be able to help with this, feel free to reach out to the Dosu Team. They'll be happy to hear your feedback! 😊

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

@crazywoola crazywoola added this to the 1.0.0 Marketplace milestone Feb 18, 2025
@zzyyll2
Copy link
Author

zzyyll2 commented Feb 19, 2025

@dosu I solved this problem by following these steps:

  1. docker exec -it docker-db-1 bash
  2. psql -d dify
  3. ALTER TABLE dataset_collection_bindings ALTER COLUMN provider_name TYPE VARCHAR(255);
  4. \d dataset_collection_bindings;
    Table "public.dataset_collection_bindings"
    Column | Type | Collation | Nullable | Default
    -----------------+-----------------------------+-----------+----------+------------------------------
    id | uuid | | not null | uuid_generate_v4()
    provider_name | character varying(255) | | not null |
    model_name | character varying(255) | | not null |
    collection_name | character varying(64) | | not null |
    created_at | timestamp without time zone | | not null | CURRENT_TIMESTAMP(0)
    type | character varying(40) | | not null | 'dataset'::character varying
    Indexes:
    "dataset_collection_bindings_pkey" PRIMARY KEY, btree (id)
    "provider_model_name_idx" btree (provider_name, model_name)

Copy link

dosubot bot commented Feb 19, 2025

Hey @zzyyll2! It sounds like you've been busy and found a solution to your issue—great job! 🎉 However, I'm here to help with bugs, technical questions, and engineering knowledge, not to review or validate solutions. If you think I should be able to help with this kind of request, feel free to reach out to the Dosu Team. They'll be happy to hear your feedback! 😊

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

@kkjinping
Copy link

@dosu I solved this problem by following these steps:

  1. docker exec -it docker-db-1 bash
  2. psql -d dify
  3. ALTER TABLE dataset_collection_bindings ALTER COLUMN provider_name TYPE VARCHAR(255);
  4. \d dataset_collection_bindings;
    Table "public.dataset_collection_bindings"
    Column | Type | Collation | Nullable | Default
    -----------------+-----------------------------+-----------+----------+------------------------------
    id | uuid | | not null | uuid_generate_v4()
    provider_name | character varying(255) | | not null |
    model_name | character varying(255) | | not null |
    collection_name | character varying(64) | | not null |
    created_at | timestamp without time zone | | not null | CURRENT_TIMESTAMP(0)
    type | character varying(40) | | not null | 'dataset'::character varying
    Indexes:
    "dataset_collection_bindings_pkey" PRIMARY KEY, btree (id)
    "provider_model_name_idx" btree (provider_name, model_name)

thank you , it help me

@KangbingZhao
Copy link

@dosu I solved this problem by following these steps:

  1. docker exec -it docker-db-1 bash
  2. psql -d dify
  3. ALTER TABLE dataset_collection_bindings ALTER COLUMN provider_name TYPE VARCHAR(255);
  4. \d dataset_collection_bindings;
    Table "public.dataset_collection_bindings"
    Column | Type | Collation | Nullable | Default
    -----------------+-----------------------------+-----------+----------+------------------------------
    id | uuid | | not null | uuid_generate_v4()
    provider_name | character varying(255) | | not null |
    model_name | character varying(255) | | not null |
    collection_name | character varying(64) | | not null |
    created_at | timestamp without time zone | | not null | CURRENT_TIMESTAMP(0)
    type | character varying(40) | | not null | 'dataset'::character varying
    Indexes:
    "dataset_collection_bindings_pkey" PRIMARY KEY, btree (id)
    "provider_model_name_idx" btree (provider_name, model_name)

It works for me as well. However, since Dify is using PostgreSQL, we can replace all instances of VARCHAR(XXX) with the text type.

@Scofield-Gu
Copy link

@dosu I solved this problem by following these steps:

  1. docker exec -it docker-db-1 bash
  2. psql -d dify
  3. ALTER TABLE dataset_collection_bindings ALTER COLUMN provider_name TYPE VARCHAR(255);
  4. \d dataset_collection_bindings;
    Table "public.dataset_collection_bindings"
    Column | Type | Collation | Nullable | Default
    -----------------+-----------------------------+-----------+----------+------------------------------
    id | uuid | | not null | uuid_generate_v4()
    provider_name | character varying(255) | | not null |
    model_name | character varying(255) | | not null |
    collection_name | character varying(64) | | not null |
    created_at | timestamp without time zone | | not null | CURRENT_TIMESTAMP(0)
    type | character varying(40) | | not null | 'dataset'::character varying
    Indexes:
    "dataset_collection_bindings_pkey" PRIMARY KEY, btree (id)
    "provider_model_name_idx" btree (provider_name, model_name)

works for me as well, but 1 point confused me is that bellow commit seems don't work after pulling the latest commit.
fix: (psycopg2.errors.StringDataRightTruncation) value too long for type character varying(40) Fixes #14593 (#14597)

baseline i used:
Author: Hantaek Lim [email protected]
Date: 2025/3/8 19:08:48
Committer: GitHub [email protected]
Commit hash: f7e012d

Fix: reranker OFF logic to preserve user setting (#15235)

Co-authored-by: crazywoola [email protected]

@Windows55
Copy link

@dosu I solved this problem by following these steps:

  1. docker exec -it docker-db-1 bash
  2. psql -d dify
  3. ALTER TABLE dataset_collection_bindings ALTER COLUMN provider_name TYPE VARCHAR(255);
  4. \d dataset_collection_bindings;
    Table "public.dataset_collection_bindings"
    Column | Type | Collation | Nullable | Default
    -----------------+-----------------------------+-----------+----------+------------------------------
    id | uuid | | not null | uuid_generate_v4()
    provider_name | character varying(255) | | not null |
    model_name | character varying(255) | | not null |
    collection_name | character varying(64) | | not null |
    created_at | timestamp without time zone | | not null | CURRENT_TIMESTAMP(0)
    type | character varying(40) | | not null | 'dataset'::character varying
    Indexes:
    "dataset_collection_bindings_pkey" PRIMARY KEY, btree (id)
    "provider_model_name_idx" btree (provider_name, model_name)

感谢 解决了本地化部署推理模型 无法导入知识库的问题
'langgenius/openai_api_compatible/openai_api_compatible' 应该去掉一个'openai_api_compatible'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants