MasterGroosha / telegram-report-bot

A simple bot to handle reports from users in your chat
MIT License
110 stars 24 forks source link

Errors with lang #5

Closed shmidtelson closed 2 years ago

shmidtelson commented 2 years ago

Hi! I have settings docker-compose a bit different I dont use env_file but use environment section and i think bot cant see my settings, because it sends me

 Incorrect value. Must be one of: en, ru (type=value_error)
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/app/bot/__main__.py", line 8, in <module>
    from bot.before_start import fetch_admins, check_rights_and_permissions
  File "/app/bot/before_start.py", line 6, in <module>
    from bot.config_reader import config
  File "/app/bot/config_reader.py", line 40, in <module>
    config = Settings()
  File "pydantic/env_settings.py", line 38, in pydantic.env_settings.BaseSettings.__init__
  File "pydantic/main.py", line 331, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for Settings
lang
MasterGroosha commented 2 years ago

Could you please show me your environment section? Or, what's better, a quick guide to help me reproduce your problem.

shmidtelson commented 2 years ago

I think that you should use this magic from python-dotenv lib It will give you access to env of container if .env doesnt exist

image

My configuration here

Screenshot 2022-05-11 at 10 46 53
MasterGroosha commented 2 years ago

Oh, my bad, could you please replace "BOT_LANGUAGE" variable with "LANG" and check if it works? It looks like I've changed its name during my switch to pydantic.

I'm not happy with how my settings are structured and their naming, so if you have any advice, please let me know.

shmidtelson commented 2 years ago

oh! okay Everything is ok! Time to close this issue

Thank you!

MasterGroosha commented 2 years ago

Please don't close the issue yet, the env_dist has incorrect variable naming. Definitely need a fix from my side.

MasterGroosha commented 2 years ago

Fixed in d30d4b3c05ba337c9f0d20b2321b6f28be0c3d95

Thank you for reporting!