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

Errors with lang #5

Closed
shmidtelson opened this issue May 11, 2022 · 6 comments
Closed

Errors with lang #5

shmidtelson opened this issue May 11, 2022 · 6 comments

Comments

@shmidtelson
Copy link

shmidtelson commented May 11, 2022

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
Copy link
Owner

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

@shmidtelson
Copy link
Author

shmidtelson commented May 11, 2022

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
Copy link
Owner

MasterGroosha commented May 11, 2022

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
Copy link
Author

shmidtelson commented May 11, 2022

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

Thank you!

@MasterGroosha
Copy link
Owner

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

@MasterGroosha
Copy link
Owner

Fixed in d30d4b3

Thank you for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants