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

Cloud't create a workflow #10229

Closed
5 tasks done
elrondwong opened this issue Nov 4, 2024 · 4 comments
Closed
5 tasks done

Cloud't create a workflow #10229

elrondwong opened this issue Nov 4, 2024 · 4 comments
Labels
🐞 bug Something isn't working 🌊 feat:workflow Workflow related stuff.

Comments

@elrondwong
Copy link

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.10.2

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

run server

flask run --host 0.0.0.0 --port=5001 --debug
celery -A app.celery worker -P gevent -c 1 --loglevel INFO -Q dataset,generation,mail,ops_trace
npm run  start

create a workflow from blank

image image

flash console log

2024-11-04 06:23:05,059.059 INFO [Thread-156 (process_request_thread)] [_internal.py:97] - 127.0.0.1 - - [04/Nov/2024 06:23:05] "GET /console/api/apps/6c488bac-4d24-47a3-9d37-6b63c936c4d7/workflows/draft HTTP/1.1" 400 -
2024-11-04 06:23:05,084.084 INFO [Thread-157 (process_request_thread)] [_internal.py:97] - 127.0.0.1 - - [04/Nov/2024 06:23:05] "GET /console/api/apps/6c488bac-4d24-47a3-9d37-6b63c936c4d7/workflows/default-workflow-block-configs HTTP/1.1" 200 -
2024-11-04 06:23:05,665.665 INFO [Thread-158 (process_request_thread)] [_internal.py:97] - 127.0.0.1 - - [04/Nov/2024 06:23:05] "GET /console/api/workspaces/current/tools/builtin HTTP/1.1" 200 -
2024-11-04 06:23:05,682.682 INFO [Thread-159 (process_request_thread)] [_internal.py:97] - 127.0.0.1 - - [04/Nov/2024 06:23:05] "GET /console/api/workspaces/current/tools/api HTTP/1.1" 200 -
2024-11-04 06:23:05,703.703 INFO [Thread-160 (process_request_thread)] [_internal.py:97] - 127.0.0.1 - - [04/Nov/2024 06:23:05] "GET /console/api/workspaces/current/tools/workflow HTTP/1.1" 200 -
2024-11-04 06:23:05,739.739 ERROR [Thread-161 (process_request_thread)] [app.py:838] - Exception on /console/api/apps/6c488bac-4d24-47a3-9d37-6b63c936c4d7/workflows/draft [POST]
Traceback (most recent call last):
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
    self.dialect.do_execute(
  File "/Users/wanggangfeng/work/ai/dify/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 "updated_at" of relation "workflows" violates not-null constraint
DETAIL:  Failing row contains (66a9c6f1-3c2e-4dfb-895d-e54859466a0c, 79577fe2-8492-4e88-a2ac-8785da7c656b, 6c488bac-4d24-47a3-9d37-6b63c936c4d7, workflow, draft, {"nodes": [{"id": "1730701384957", "type": "custom", "data": {"t..., {"retriever_resource": {"enabled": true}, "file_upload": {}, "te..., 9188cc89-59c7-41e5-bc50-7ee8517e1677, 2024-11-04 06:23:06, null, null, {}, {}).


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper
    resp = resource(*args, **kwargs)
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view
    return current_app.ensure_sync(self.dispatch_request)(**kwargs)  # type: ignore[no-any-return]
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/Users/wanggangfeng/work/ai/dify/api/controllers/console/wraps.py", line 142, in decorated
    return view(*args, **kwargs)
  File "/Users/wanggangfeng/work/ai/dify/api/libs/login.py", line 92, in decorated_view
    return current_app.ensure_sync(func)(*args, **kwargs)
  File "/Users/wanggangfeng/work/ai/dify/api/controllers/console/wraps.py", line 26, in decorated
    return view(*args, **kwargs)
  File "/Users/wanggangfeng/work/ai/dify/api/controllers/console/app/wraps.py", line 49, in decorated_view
    return view_func(*args, **kwargs)
  File "/Users/wanggangfeng/work/ai/dify/api/controllers/console/app/workflow.py", line 110, in post
    workflow = workflow_service.sync_draft_workflow(
  File "/Users/wanggangfeng/work/ai/dify/api/services/workflow_service.py", line 123, in sync_draft_workflow
    db.session.commit()
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/scoping.py", line 597, in commit
    return self._proxied.commit()
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 2028, in commit
    trans.commit(_to_root=True)
  File "<string>", line 2, in commit
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go
    ret_value = fn(self, *arg, **kw)
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1313, in commit
    self._prepare_impl()
  File "<string>", line 2, in _prepare_impl
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go
    ret_value = fn(self, *arg, **kw)
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1288, in _prepare_impl
    self.session.flush()
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 4352, in flush
    self._flush(objects)
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 4487, in _flush
    with util.safe_reraise():
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 4448, in _flush
    flush_context.execute()
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py", line 466, in execute
    rec.execute(self)
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py", line 642, in execute
    util.preloaded.orm_persistence.save_obj(
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/persistence.py", line 93, in save_obj
    _emit_insert_statements(
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/orm/persistence.py", line 1233, in _emit_insert_statements
    result = connection.execute(
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1418, in execute
    return meth(
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/sql/elements.py", line 515, in _execute_on_connection
    return connection._execute_clauseelement(
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1640, in _execute_clauseelement
    ret = self._execute_context(
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1846, in _execute_context
    return self._exec_single_context(
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1986, in _exec_single_context
    self._handle_dbapi_exception(
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2355, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
    self.dialect.do_execute(
  File "/Users/wanggangfeng/work/ai/dify/api/.venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) null value in column "updated_at" of relation "workflows" violates not-null constraint
DETAIL:  Failing row contains (66a9c6f1-3c2e-4dfb-895d-e54859466a0c, 79577fe2-8492-4e88-a2ac-8785da7c656b, 6c488bac-4d24-47a3-9d37-6b63c936c4d7, workflow, draft, {"nodes": [{"id": "1730701384957", "type": "custom", "data": {"t..., {"retriever_resource": {"enabled": true}, "file_upload": {}, "te..., 9188cc89-59c7-41e5-bc50-7ee8517e1677, 2024-11-04 06:23:06, null, null, {}, {}).

[SQL: INSERT INTO workflows (tenant_id, app_id, type, version, graph, features, created_by, updated_by, updated_at, environment_variables, conversation_variables) VALUES (%(tenant_id)s::UUID, %(app_id)s::UUID, %(type)s, %(version)s, %(graph)s, %(features)s, %(created_by)s::UUID, %(updated_by)s::UUID, %(updated_at)s, %(environment_variables)s, %(conversation_variables)s) RETURNING workflows.id, workflows.created_at]
[parameters: {'tenant_id': '79577fe2-8492-4e88-a2ac-8785da7c656b', 'app_id': '6c488bac-4d24-47a3-9d37-6b63c936c4d7', 'type': 'workflow', 'version': 'draft', 'graph': '{"nodes": [{"id": "1730701384957", "type": "custom", "data": {"type": "start", "title": "Start", "desc": "", "variables": []}, "position": {"x": 80, "y": 282}, "targetPosition": "left", "sourcePosition": "right"}], "edges": []}', 'features': '{"retriever_resource": {"enabled": true}, "file_upload": {}, "text_to_speech": {"enabled": false, "voice": "", "language": ""}, "sensitive_word_avoidance": {"enabled": false}}', 'created_by': '9188cc89-59c7-41e5-bc50-7ee8517e1677', 'updated_by': None, 'updated_at': None, 'environment_variables': '{}', 'conversation_variables': '{}'}]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
2024-11-04 06:23:05,744.744 INFO [Thread-161 (process_request_thread)] [_internal.py:97] - 127.0.0.1 - - [04/Nov/2024 06:23:05] "POST /console/api/apps/6c488bac-4d24-47a3-9d37-6b63c936c4d7/workflows/draft HTTP/1.1" 500 -

✔️ Expected Behavior

Create workflow from blank successfully

❌ Actual Behavior

UI hangging
api logging erros

Copy link

dosubot bot commented Nov 4, 2024

Hello, @elrondwong! I'm here to help you with any bugs, questions, or contributions. Let's work together to solve the issue you're facing.

The error you're encountering, "null value in column 'updated_at' of relation 'workflows' violates not-null constraint," is due to the updated_at field not being set when creating a new workflow. This field is expected to have a value, and the application logic should ensure it is set.

To resolve this issue, ensure that the updated_at field is assigned a value when creating or updating a workflow. In the Dify application, this is typically done by setting the updated_at field to the current UTC time using datetime.now(timezone.utc).replace(tzinfo=None) in the sync_draft_workflow method [1][2].

Check your application code to ensure that this logic is correctly implemented and that the updated_at field is being set appropriately during the workflow creation process.

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added 🌊 feat:workflow Workflow related stuff. 🐞 bug Something isn't working labels Nov 4, 2024
@crazywoola
Copy link
Member

Please run the migration before run those commands.

@elrondwong
Copy link
Author

how to migration, first run

@elrondwong
Copy link
Author

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

No branches or pull requests

2 participants