Skip to content

fix: safely log dictionary payloads in UrlInvoker to prevent TypeErrors#64

Open
Dreamstick9 wants to merge 2 commits into
google:mainfrom
Dreamstick9:fix/connector-dict-join-bug
Open

fix: safely log dictionary payloads in UrlInvoker to prevent TypeErrors#64
Dreamstick9 wants to merge 2 commits into
google:mainfrom
Dreamstick9:fix/connector-dict-join-bug

Conversation

@Dreamstick9

Copy link
Copy Markdown

Fixes #63

What does this PR do?

Fixes a bug in the UrlInvoker.invoke() method that caused a TypeError when 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 a TypeError: sequence item 0: expected str instance, dict found.

Furthermore, because this line was wrapped in a broad try...except block, the application would catch the TypeError and log that instead of the actual API error payload, effectively masking the root cause of API failures from developers.

How was it fixed?

  • Updated the failure logging logic in util/connectors.py.
  • Added a list comprehension to safely convert dictionary bodies into JSON strings using json.dumps() (or fallback to str()) 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.

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.

Bug: TypeError in UrlInvoker when logging failed Graph API batch responses

1 participant