fix: safely log dictionary payloads in UrlInvoker to prevent TypeErrors#64
Open
Dreamstick9 wants to merge 2 commits into
Open
fix: safely log dictionary payloads in UrlInvoker to prevent TypeErrors#64Dreamstick9 wants to merge 2 commits into
Dreamstick9 wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #63
What does this PR do?
Fixes a bug in the
UrlInvoker.invoke()method that caused aTypeErrorwhen attempting to log failed Microsoft Graph API batch responses.Why is this necessary?
When the MS Graph API returns an error for a batch request (e.g., 400 or 500 status codes), the response
"body"is parsed by the requests library into a Python dictionary. The existing logging mechanism attempted to execute",".join()directly on these dictionary objects, which resulted in aTypeError: sequence item 0: expected str instance, dict found.Furthermore, because this line was wrapped in a broad
try...exceptblock, the application would catch theTypeErrorand log that instead of the actual API error payload, effectively masking the root cause of API failures from developers.How was it fixed?
util/connectors.py.json.dumps()(or fallback tostr()) before applying the.join()method.This ensures that the actual Microsoft API error messages (e.g.,
{"error": {"message": "Invalid ID"}}) are correctly serialized and logged for debugging.