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

PostgresConfig should error on unknown SSL_MODES #16764

Open
ikonst opened this issue Jan 31, 2024 · 0 comments
Open

PostgresConfig should error on unknown SSL_MODES #16764

ikonst opened this issue Jan 31, 2024 · 0 comments

Comments

@ikonst
Copy link

ikonst commented Jan 31, 2024

PostgresConfig should error on unknown SSL_MODES rather than leaving ssl_mode unset, as it does here:

ssl = instance.get('ssl', "allow")
if ssl in SSL_MODES:
self.ssl_mode = ssl

Otherwise it fails down the line with a more cryptic error. For example, I had my ssl parameter set to "true"`, which resulted in

{
  "message": "'PostgresConfig' object has no attribute 'ssl_mode'",
  "traceback": "Traceback (most recent call last):\n  File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.9/site-packages/datadog_checks/base/checks/base.py\", line 1210, in run\n    initialization()\n  File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.9/site-packages/datadog_checks/postgres/postgres.py\", line 740, in _connect\n    with self.db():\n  File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.9/contextlib.py\", line 119, in __enter__\n    return next(self.gen)\n  File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.9/site-packages/datadog_checks/postgres/postgres.py\", line 200, in db\n    self._db = self._new_connection(self._config.dbname)\n  File \"/app/.apt/opt/datadog-agent/embedded/lib/python3.9/site-packages/datadog_checks/postgres/postgres.py\", line 714, in _new_connection\n    'sslmode': self._config.ssl_mode,\nAttributeError: 'PostgresConfig' object has no attribute 'ssl_mode'\n"
}
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