API container crashes with ValueError: Unknown level: 'warn' #5524

Closed
opened 2026-02-21 18:11:26 -05:00 by yindo · 2 comments
Owner

Originally created by @sammcj 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.8.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Start the API container
  2. Try to login for the first time
  3. Note that nothing happens when you press submit
  4. Check api container logs
Running migrations
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
sagemaker.config INFO - Not applying SDK defaults from location: /etc/xdg/sagemaker/config.yaml
sagemaker.config INFO - Not applying SDK defaults from location: /root/.config/sagemaker/config.yaml
INFO:matplotlib.font_manager:generated new fontManager
Traceback (most recent call last):
  File "/app/api/.venv/bin/flask", line 8, in <module>
    sys.exit(main())
  File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 1105, in main
    cli.main()
  File "/app/api/.venv/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/app/api/.venv/lib/python3.10/site-packages/click/core.py", line 1682, in invoke
    cmd_name, cmd, args = self.resolve_command(ctx, args)
  File "/app/api/.venv/lib/python3.10/site-packages/click/core.py", line 1729, in resolve_command
    cmd = self.get_command(ctx, cmd_name)
  File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 611, in get_command
    app = info.load_app()
  File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 335, in load_app
    app = locate_app(import_name, name)
  File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 245, in locate_app
    __import__(module_name)
  File "/app/api/app.py", line 246, in <module>
    app = create_app()
  File "/app/api/app.py", line 120, in create_app
    logging.basicConfig(
  File "/usr/local/lib/python3.10/logging/__init__.py", line 2059, in basicConfig
    root.setLevel(level)
  File "/usr/local/lib/python3.10/logging/__init__.py", line 1452, in setLevel
    self.level = _checkLevel(level)
  File "/usr/local/lib/python3.10/logging/__init__.py", line 198, in _checkLevel
    raise ValueError("Unknown level: %r" % level)
ValueError: Unknown level: 'warn'

I'm not sure where it's getting 'warn' from but I suspect it's hard coded as it's not in my compose or env files.

Also None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used. does not look right?

✔️ Expected Behavior

the api container starts

Actual Behavior

the api container throws errors

Originally created by @sammcj 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.8.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Start the API container 2. Try to login for the first time 3. Note that nothing happens when you press submit 4. Check api container logs ``` Running migrations None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used. sagemaker.config INFO - Not applying SDK defaults from location: /etc/xdg/sagemaker/config.yaml sagemaker.config INFO - Not applying SDK defaults from location: /root/.config/sagemaker/config.yaml INFO:matplotlib.font_manager:generated new fontManager Traceback (most recent call last): File "/app/api/.venv/bin/flask", line 8, in <module> sys.exit(main()) File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 1105, in main cli.main() File "/app/api/.venv/lib/python3.10/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/app/api/.venv/lib/python3.10/site-packages/click/core.py", line 1682, in invoke cmd_name, cmd, args = self.resolve_command(ctx, args) File "/app/api/.venv/lib/python3.10/site-packages/click/core.py", line 1729, in resolve_command cmd = self.get_command(ctx, cmd_name) File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 611, in get_command app = info.load_app() File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 335, in load_app app = locate_app(import_name, name) File "/app/api/.venv/lib/python3.10/site-packages/flask/cli.py", line 245, in locate_app __import__(module_name) File "/app/api/app.py", line 246, in <module> app = create_app() File "/app/api/app.py", line 120, in create_app logging.basicConfig( File "/usr/local/lib/python3.10/logging/__init__.py", line 2059, in basicConfig root.setLevel(level) File "/usr/local/lib/python3.10/logging/__init__.py", line 1452, in setLevel self.level = _checkLevel(level) File "/usr/local/lib/python3.10/logging/__init__.py", line 198, in _checkLevel raise ValueError("Unknown level: %r" % level) ValueError: Unknown level: 'warn' ``` I'm not sure where it's getting 'warn' from but I suspect it's hard coded as it's not in my compose or env files. Also `None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.` does not look right? ### ✔️ Expected Behavior the api container starts ### ❌ Actual Behavior the api container throws errors
yindo added the 🐞 bug label 2026-02-21 18:11:26 -05:00
yindo closed this issue 2026-02-21 18:11:26 -05:00
Author
Owner

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

Hello, @sammcj! I'm here to assist you with bug fixes, answer your questions, and guide you to become a contributor. Let's work together to solve the issue you're facing.

The error "ValueError: Unknown level: 'warn'" occurs because the LOG_LEVEL environment variable is set to an invalid value. The valid log levels are INFO and ERROR. The value warn is not recognized.

To fix this issue, set the LOG_LEVEL environment variable to a valid value, such as INFO or ERROR.

Example:

export LOG_LEVEL=INFO

Or in your Docker environment configuration:

environment:
  - LOG_LEVEL=INFO

According to the Dify documentation, the default log level is INFO, and it is recommended to set it to ERROR in a production environment [1][2].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 10, 2024): <!-- Greeting --> Hello, @sammcj! I'm here to assist you with bug fixes, answer your questions, and guide you to become a contributor. Let's work together to solve the issue you're facing. <!-- Answer --> The error "ValueError: Unknown level: 'warn'" occurs because the `LOG_LEVEL` environment variable is set to an invalid value. The valid log levels are `INFO` and `ERROR`. The value `warn` is not recognized. To fix this issue, set the `LOG_LEVEL` environment variable to a valid value, such as `INFO` or `ERROR`. Example: ```bash export LOG_LEVEL=INFO ``` Or in your Docker environment configuration: ```yaml environment: - LOG_LEVEL=INFO ``` According to the Dify documentation, the default log level is `INFO`, and it is recommended to set it to `ERROR` in a production environment <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/getting-started/install-self-hosted/environments.md)</sup><sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/jp/getting-started/install-self-hosted/environments.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@sammcj commented on GitHub (Sep 10, 2024):

OK it seems the LOG_LEVEL in the .env file has no effect on the api container, forcing it in the environment: seemed to fix it :/

@sammcj commented on GitHub (Sep 10, 2024): OK it seems the LOG_LEVEL in the .env file has no effect on the api container, forcing it in the environment: seemed to fix it :/
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5524