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

Potential logical error #283

Open
ZirongCai opened this issue Dec 9, 2024 · 0 comments
Open

Potential logical error #283

ZirongCai opened this issue Dec 9, 2024 · 0 comments

Comments

@ZirongCai
Copy link

ZirongCai commented Dec 9, 2024

What happened:
the delivery-service shows such error

2024-12-09 09:51:39,710 [WARNING] k8s.util: no bdba-cfg found for internal
2024-12-09 09:51:39,723 [ERROR] middleware.errors: Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/middleware/errors.py", line 20, in middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/middleware/auth.py", line 588, in middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/middleware/db_session.py", line 32, in middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/middleware/route_feature_check.py", line 49, in middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/aiohttp/web_urldispatcher.py", line 975, in _iter
    ret = await method()
          ^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/service_extensions.py", line 197, in get
    data=k8s.util.iter_scan_configurations(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/k8s/util.py", line 260, in iter_scan_configurations
    if bdba_cfg:
       ^^^^^^^^
UnboundLocalError: cannot access local variable 'bdba_cfg' where it is not associated with a value

original code first tries to get bdba_cfg in a try-except logic, but the bdba_cfg is anyway accessed later in the if statement which in this case results the error shown above.

Besides that:

my cfg_factory looks like following:

{
  "bdba": {
    "internal": {
      "api_url": "*",
      "credentials": {
        "auth_scheme": "bearer_token",
        "password": "*",
        "token": "*",
        "username": "*"
      },
      "group_ids": [
        *
      ],
      "tls_verify": true
    }
  },

so i do not understand why no bdba-cfg found for internal error pops up
What you expected to happen:

bdba_cfg should only be used when try block succeeded.

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know:

Environment:

@ZirongCai ZirongCai reopened this Dec 10, 2024
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

1 participant