save app info error #5395

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

Originally created by @kenneth-bro on GitHub (Sep 4, 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.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

image

2024-09-05 10:35:38,398.398 ERROR [Dummy-37] [app.py:838] - Exception on /console/api/apps/b1d99136-e93a-4bcd-9558-6bc3b29744e0 [PUT]
Traceback (most recent call last):
File "/app/api/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
self.dialect.do_execute(
File "/app/api/.venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.NotNullViolation: null value in column "use_icon_as_answer_icon" of relation "apps" violates not-null constraint

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @kenneth-bro on GitHub (Sep 4, 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.3 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ![image](https://github.com/user-attachments/assets/8135c34f-0518-4e47-b4bf-9c1cb629d0ca) 2024-09-05 10:35:38,398.398 ERROR [Dummy-37] [app.py:838] - Exception on /console/api/apps/b1d99136-e93a-4bcd-9558-6bc3b29744e0 [PUT] Traceback (most recent call last): File "/app/api/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context self.dialect.do_execute( File "/app/api/.venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute cursor.execute(statement, parameters) psycopg2.errors.NotNullViolation: null value in column "use_icon_as_answer_icon" of relation "apps" violates not-null constraint ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:10:47 -05:00
yindo closed this issue 2026-02-21 18:10:47 -05:00
Author
Owner

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

The error you're encountering, "null value in column 'use_icon_as_answer_icon' of relation 'apps' violates not-null constraint," occurs because the use_icon_as_answer_icon column in the apps table is defined with a NOT NULL constraint and a default value of false. This means that when you try to save app information, you must provide a value for this column, or it will default to false.

To resolve this error, ensure that when you are saving app information, you either provide a value for the use_icon_as_answer_icon field or allow it to use the default value of false. For example:

new_app = App(
    tenant_id=some_tenant_id,
    name="Some App Name",
    description="Some description",
    mode="Some mode",
    icon="Some icon",
    icon_background="Some background",
    enable_site=True,
    enable_api=True,
    # other required fields...
    use_icon_as_answer_icon=False  # or omit this field to use the default value
)
db.session.add(new_app)
db.session.commit()

Make sure that your data insertion logic includes the use_icon_as_answer_icon field or relies on the default value [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 4, 2024): <!-- Answer --> The error you're encountering, "null value in column 'use_icon_as_answer_icon' of relation 'apps' violates not-null constraint," occurs because the `use_icon_as_answer_icon` column in the `apps` table is defined with a `NOT NULL` constraint and a default value of `false`. This means that when you try to save app information, you must provide a value for this column, or it will default to `false`. To resolve this error, ensure that when you are saving app information, you either provide a value for the `use_icon_as_answer_icon` field or allow it to use the default value of `false`. For example: ```py new_app = App( tenant_id=some_tenant_id, name="Some App Name", description="Some description", mode="Some mode", icon="Some icon", icon_background="Some background", enable_site=True, enable_api=True, # other required fields... use_icon_as_answer_icon=False # or omit this field to use the default value ) db.session.add(new_app) db.session.commit() ``` Make sure that your data insertion logic includes the `use_icon_as_answer_icon` field or relies on the default value <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/models/model.py)</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#5395