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

move config parsing to own module #686

Merged
merged 4 commits into from
Oct 11, 2024
Merged

move config parsing to own module #686

merged 4 commits into from
Oct 11, 2024

Conversation

brassy-endomorph
Copy link
Collaborator

@brassy-endomorph brassy-endomorph commented Oct 10, 2024

fixes #637

This is a minimal change to organize the config parsing (somewhat) according to some logic that seemed reasonable to me (for now). There are some slight change in the parsing logic so we don't set empty/None values in a bunch of places since this make some logic a little cleaner so we can do tests like if "KEY" in app.config which is different than if app.config.get("KEY").

  • moves all config parsing to config.py
  • parses random env vars prefixed with HL_CFG_
  • parses randm env vars prefixed with HL_CFG_JSON_ as JSON
  • basic tests for parsing
  • updated docs
  • bumped dependencies because somehow that fixed linting (???)

@glenn-sorrentino
Copy link
Member

Loggin in causes this:

    File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/flask/app.py", line 1498, in __call__

    return self.wsgi_app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/flask/app.py", line 1476, in wsgi_app

    response = self.handle_exception(e)
               ^^^^^^^^^^^^^^^^^^^^^^^^

    File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app

    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request

    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request

    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^

    File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/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 "/app/hushline/routes.py", line 412, in login

    if app.config["STRIPE_SECRET_KEY"]:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    KeyError: 'STRIPE_SECRET_KEY'

@brassy-endomorph
Copy link
Collaborator Author

I didn't actually test it yet. Just got it to pass CI, and this check is whether this method looks sensible. But yes, noted.

@brassy-endomorph brassy-endomorph merged commit 386a24c into main Oct 11, 2024
7 checks passed
@brassy-endomorph brassy-endomorph deleted the config-parsing branch October 11, 2024 16:48
@glenn-sorrentino glenn-sorrentino restored the config-parsing branch October 16, 2024 15:41
glenn-sorrentino added a commit that referenced this pull request Oct 16, 2024
This reverts commit 386a24c, reversing
changes made to d53f7ff.
scidsg-dev added a commit that referenced this pull request Oct 16, 2024
Revert "Merge pull request #686 from scidsg/config-parsing"
brassy-endomorph added a commit that referenced this pull request Oct 16, 2024
brassy-endomorph added a commit that referenced this pull request Oct 16, 2024
Revert "Revert "Merge pull request #686 from scidsg/config-parsing""
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

Successfully merging this pull request may close these issues.

Parse env vars into Config object before configuring Flask object
2 participants