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

Improve visibility for access_key token exception in get_token() #198

Merged
merged 7 commits into from
May 31, 2023

Conversation

MeganerdDev
Copy link
Contributor

@MeganerdDev MeganerdDev commented May 10, 2023

Closes: #197

What's Changed

Adds a try/except block for slicing access_token from response
Adds error logger message to stdout on exception slicing get_token() response.json()["access_key"]
Adds debug logger message to stdout on get_token() that prints json response data

TODO

  • Explanation of Change(s)
  • Added change log fragment(s) (for more information see the documentation)
  • Attached Screenshots, Payload Example
  • Unit, Integration Tests
  • Documentation Updates (when adding/changing features)
  • Outline Remaining Work, Constraints from Design

Add try/except block for slicing access_token from response
Add debug logger stdout on exception
Added debug log message
token = response.json()["access_token"]
except(KeyError) :
logger.error("ERROR: get_token() response is missing access_token key")
raise KeyError("get_token() response is missing access_token key")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think something that adds language about where to look when this happens would be helpful.

raise KeyError("get_token() response is missing access_token key which indicates an error communicating with MS Teams. Check the app_id and app_secret.")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to:
"get_token() response is missing access_token key, which indicates an error communicating with MS Teams. Check the app_id and app_secret."

More verbosity for error
@mattmiller87 mattmiller87 marked this pull request as ready for review May 17, 2023 18:07
@jvanderaa
Copy link
Contributor

@MeganerdDev I think this makes sense, but we do need to get the tests passing.

Copy link
Contributor

@smk4664 smk4664 left a comment

Choose a reason for hiding this comment

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

Thanks for adding this debugging, this will be very helpful in troubleshooting MS Teams issues.

@smk4664 smk4664 merged commit 89385bc into nautobot:develop May 31, 2023
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.

Improve visibility for access_key token exception in get_token()
4 participants