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

Open Beginner friendly
#63 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
api

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google/migration-planner

All issues in google/migration-planner

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.