Skip to content

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

@Dreamstick9

Description

@Dreamstick9

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions