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

Bug: The application tries to use credentials to access the database that have already expired #105

Closed
obervinov opened this issue Oct 13, 2024 · 0 comments · Fixed by #111
Assignees
Labels
bug Something isn't working
Milestone

Comments

@obervinov
Copy link
Owner

obervinov commented Oct 13, 2024

Describe the bug
The application tries to use credentials to access the database that have already expired, causing the thread to crash.
Error message:

[2024-10-13 08:51:46,186] ERROR [logger.logger:handle:29] [Bot]: Error: permission denied for table users

Exception in thread WorkerThread1:
Traceback (most recent call last):
  File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/util.py", line 93, in run
    task(*args, **kwargs)
  File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/__init__.py", line 8945, in _run_middlewares_and_handler
    result = handler['function'](message)
  File "/home/pyinstabot-downloader/app/src/bot.py", line 127, in bot_callback_query_handler
    if users.user_access_check(**requestor).get('permissions', None) == users.user_status_allow:
  File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/users/users.py", line 207, in user_access_check
    self.storage.register_user(
  File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/users/storage.py", line 80, in register_user
    self.cursor.execute(f"INSERT INTO users (user_id, chat_id, status) VALUES ('{user_id}', '{chat_id}', '{status}')")
psycopg2.errors.InsufficientPrivilege: permission denied for table users


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/threading.py", line 980, in _bootstrap_inner
    self.run()
  File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/util.py", line 103, in run
    self.exception_callback(self, self.exception_info)
  File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telebot/util.py", line 140, in on_exception
    handled = self.telebot.exception_handler.handle(exc_info)
  File "/home/pyinstabot-downloader/app/.venv/lib/python3.9/site-packages/telegram/telegram.py", line 30, in handle
    raise FailedToCreateInstance("Failed to create the bot instance.") from exception
telegram.exceptions.FailedToCreateInstance: Failed to create the bot instance.

Additional context
This will probably be fixed in users-package (because that module generates the credentials itself).

Possible correction
Intercept error during psql role revocation (regeneration of credentials via vault database engine) and retrieve actual authentication data.
Or consider other ways to prevent the application from encountering this error.

Screenshots
None

Check list after fixing the bug
None

@obervinov obervinov added the bug Something isn't working label Oct 13, 2024
@obervinov obervinov self-assigned this Oct 13, 2024
@obervinov obervinov added this to the v3.1.0 milestone Oct 22, 2024
obervinov added a commit that referenced this issue Oct 23, 2024
)

## v3.1.0 - 2024-10-23
### What's Changed
**Full Changelog**: v3.0.0...v3.1.0 by @obervinov in #111
#### 🚀 Features
* bump workflows to `2.0.2`
* bump dependencies versions
#### 💥 Breaking Changes
* bump python version to `3.12`
#### 🐛 Bug Fixes
* other general bug fixes and improvements
* fix not enough condition for `igtv` type of content for `Downloader` class
* fix infinite loop in the `Downloader` class when type of content not supported in condition
* #104
* #105
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

1 participant