8000 API Key usage counter going out of range · Issue #1978 · alerta/alerta · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

API Key usage counter going out of range #1978

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

Open
rlikhachev opened this issue Aug 9, 2024 · 0 comments
Open

API Key usage counter going out of range #1978

rlikhachev opened this issue Aug 9, 2024 · 0 comments

Comments

@rlikhachev
Copy link

Issue Summary
When a service generate a lot of alerts API Key usage counter going out of range on Postgres data base.

Environment

  • OS: Linux

  • API version: [eg. 6.8.1]

  • Deployment: self-hosted

  • For self-hosted, WSGI environment: [eg. nginx/uwsgi, apache/mod_wsgi]

  • Database: Postgres

  • Server config:
    Auth enabled: Yes
    Auth provider: OpenID

  • server version 9.0.1

To Reproduce
Steps to reproduce the behavior:

  1. generate over 2147483647 alert using one API Key
  2. generate additional alert
  3. See error (include command output)
2024-08-06 08:38:33,854 - alerta.app[7784]: ERROR - integer out of range
 [in /app/./alerta/exceptions.py:126]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/usr/local/lib/python3.9/site-packages/flask_cors/decorator.py", line 128, in wrapped_function
    resp = make_response(f(*args, **kwargs))
  File "/app/./alerta/auth/decorators.py", line 42, in wrapped
    key_info = ApiKey.verify_key(key)
  File "/app/./alerta/models/key.py", line 165, in verify_key
    db.update_key_last_used(key)
  File "/app/./alerta/database/backends/postgres/base.py", line 1065, in update_key_last_used
    return self._updateone(update, (key, key))
  File "/app/./alerta/database/backends/postgres/base.py", line 1632, in _updateone
    cursor.execute(query, vars)
  File "/usr/local/lib/python3.9/site-packages/psycopg2/extras.py", line 312, in execute
    return super().execute(query, vars)
psycopg2.errors.NumericValueOutOfRange: integer out of range

Expected behavior
Python threats conversion from integer to long (bigint) automatically , so when value overgrowth integer size it change it type to long 'under the hood' and no code changes required, but Postgres is strict typed, and unable to handle long value into integer field.
So make the 'count' field as bigint type will resolve this issue

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
0