Bug: TypeError in UrlInvoker when logging failed Graph API batch responses
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in util/connectors.py, focusing on UrlInvoker.invoke() around the failed_responses logging near line 84. Reproduce or inspect a failed batch response with a JSON body, then verify that the underlying Microsoft Graph error payload is logged without the logging path raising a TypeError.
Written by the indexing model from the issue text.
Description
Description
There is a bug in util/connectors.py inside the UrlInvoker.invoke() method that prevents actual Microsoft Graph API errors from being logged.
When a batch request fails (e.g., a 400 or 500 status code), the MS Graph API returns a JSON error response. The requests library parses this JSON body into a Python dictionary. However, the logging mechanism attempts to use ",".join() directly on these dictionary objects, which causes a type mismatch crash.
Root Cause
Around line 84 in util/connectors.py:
if len(failed_responses) > 0:
logger(f"Consistent failures observed for the following: {','.join(response.get('body') for response in failed_responses)}")
Because response.get("body") is a dict, ",".join() throws a TypeError: sequence item 0: expected str instance, dict found.
Furthermore, because this line is wrapped inside a broad try...except Exception as e: block, the TypeError is caught and logged as the actual error. This completely masks the underlying MS Graph API error, making it incredibly difficult to debug API failures.
Expected Behavior
The application should safely stringify the API error payload and log it, allowing developers to see exactly why the Graph API rejected the request (e.g., {"error": {"message": "Invalid ID"}}).
Actual Behavior
The application swallows the API error and instead logs a Python syntax error:
Error in : sequence item 0: expected str instance, dict found
- Dominant language
- Python
- Stars
- 29
- Forks
- 20
- Avg merge
- 5h 21m
- Merged PRs (30d)
- 47
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google/migration-planner
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
google/migration-planner#152 · 1 comment ·
All issues in google/migration-planner
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100