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

NameError: name 'logger' is not defined #21

Open
satoridev01 opened this issue Jan 30, 2025 · 2 comments · May be fixed by #19
Open

NameError: name 'logger' is not defined #21

satoridev01 opened this issue Jan 30, 2025 · 2 comments · May be fixed by #19

Comments

@satoridev01
Copy link

Hi !

The following stacktrace was shown when running against the repo ludwig-ai/ludwig (but it was triggered by a GitHub GraphQL error, it may happen with other repositories as it cannot be reproduced with that one exactly)

This is the Traceback:

Traceback (most recent call last):
  File "/tmp/gh-workflow-auditor/main.py", line 60, in <module>
    main()
  File "/tmp/gh-workflow-auditor/main.py", line 58, in main
    action_auditor.action_audit()
  File "/tmp/gh-workflow-auditor/action_auditor.py", line 29, in action_audit
    self.check_usernames(usernames)
  File "/tmp/gh-workflow-auditor/action_auditor.py", line 22, in check_usernames
    renamed_or_not = self.gh.stale_checker(username=username)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/gh-workflow-auditor/github_wrapper.py", line 118, in stale_checker
    is_it_user = self.call_graphql(query=user_query)['data']['user']
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/gh-workflow-auditor/github_wrapper.py", line 49, in call_graphql
    logger.error(f"GitHub GraphQL Query failed: {message}")
    ^^^^^^
NameError: name 'logger' is not defined

I believe the error happens in https://github.com/TinderSec/gh-workflow-auditor/blob/main/github_wrapper.py#L49:

logger.error(f"GitHub GraphQL Query failed: {message}")

I believe that that line should be:

self.logger.error(f"GitHub GraphQL Query failed: {message}")

When the class is initialized the logger of the object is defined and referenced with self.logger, except only for that one. Referencing the self logger should do the trick to properly log the error.

Image
@Xenorf
Copy link

Xenorf commented Feb 5, 2025

Hello @satoridev01, I made a PR #19 that should fix this behavior. It was not yet accepted but you can take a look at it 😉

@satoridev01
Copy link
Author

Agree, https://github.com/TinderSec/gh-workflow-auditor/pull/19/files#diff-8a846e356d747dd515192b9b46c5319123461f9ab81eb86953448b1b2bd85fabR79 covers that bug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants