Skip to content

Conversation

@Joris-van-der-Wel
Copy link
Contributor

@Joris-van-der-Wel Joris-van-der-Wel commented Jan 18, 2023

SUMMARY

On some of our systems the postgresql_query task failed with the following error:

AttributeError: module 'psycopg2' has no attribute 'extras'

Applying the patch from this commit fixed the issue for me on those systems. This was previously reported in issue #283. However now that some time has passed, I am unable to reproduce the issue on our newer systems.

In any case, this is still a mistake that could cause problems in the future, so I think it would be better to fix it.

The reason that this mistake is not causing any actual errors in normal situations is because of how the python import system functions: All of the entrypoints (all the source files under plugins/modules) have an import for psycopg2.extras. This causes extras to be available on psycopg2 for any code (in any module) that executes after that import statement, such as the function bodies in module_utils/postgres.py.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

community.postgresql

ADDITIONAL INFORMATION

Fixes #283

On some of our systems the `postgresql_query` task failed with the following error:

    AttributeError: module 'psycopg2' has no attribute 'extras'

Applying the patch from this commit fixed the issue for me on those systems. This was previously reported in issue #283. However now that some time has passed, I am unable to reproduce the issue on our newer systems.

In any case, this is still a mistake that could cause problems in the future, so I think it would be better to fix it.

The reason that this mistake is not causing any actual errors in normal situations is because of how the python import system functions: All of the entrypoints (all the source files under plugins/modules) have an import for `psycopg2.extras`. This causes `extras` to be available on `psycopg2` for any code (in any module) that executes after that import statement, such as the function bodies in `module_utils/postgres.py`.

Fixes #283
Copy link
Collaborator

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Joris-van-der-Wel thanks for the PR! LGTM

Could you please add a changelog fragment so that our users will see your fix in the collection's changelog?

Fixes #283
(this ^ will automatically close the issue after the PR gets merged)

Thanks

Copy link
Collaborator

@hunleyd hunleyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls re-request review once a changelog fragment has been added. thanks!

@Andersson007
Copy link
Collaborator

@Joris-van-der-Wel could you please take a look ^. If it's an issue for you, let us know, we merge it as-is and they will add the fragment ourselves

@Joris-van-der-Wel Joris-van-der-Wel requested review from hunleyd and removed request for jchancojr January 27, 2023 15:27
@hunleyd hunleyd merged commit bbaee4f into ansible-collections:main Jan 30, 2023
@patchback
Copy link

patchback bot commented Jan 30, 2023

Backport to stable-1: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-1/bbaee4fe8214bd67f1d3af51aff3e5ac7e54f54b/pr-399

Backported as #405

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jan 30, 2023
Fixes #283

(cherry picked from commit bbaee4f)
@Andersson007
Copy link
Collaborator

@Joris-van-der-Wel thanks for the contribution! @hunleyd thanks for reviewing and mergin!

@Joris-van-der-Wel if you're not on Matrix yet, you're welcome to join our room!

Andersson007 pushed a commit that referenced this pull request Jan 31, 2023
Fixes #283

(cherry picked from commit bbaee4f)

Co-authored-by: Joris <joris@jorisvanderwel.com>
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.

Missing psycopg2.extras import

3 participants