Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Bug] Redirects not being followed

Open
#744 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
api, backend

Research direction

Start by comparing the redirect handling around commit d9180bb and the client options used by GraphClientFactory.create_with_default_middleware. Reproduce the Microsoft Graph driveItem content request, trace why the 302 Location response is not followed despite RedirectHandlerOption, and verify that redirects are followed again with a regression test.

Written by the indexing model from the issue text.

Description

A bug has been introduced in version 1.13.0 of microsoft-kiota-http: redirects aren't being followed correctly.

For example, to download a driveItem from the MS Graph API (docs link) you make a call to /drives/{drive-id}/items/{item-id}/content and get back an empty 302 Found response with the Location header set to the actual download URL.

The below is an extract of the httpx logs from version 1.13.0. You can see the Location header is successfully returned, but no redirect is made.

DEBUG [2026-09-21 08:53:37] httpcore.http11 - send_request_headers.started request=<Request [b'GET']>
DEBUG [2026-09-21 08:53:37] httpcore.http11 - send_request_headers.complete
DEBUG [2026-09-21 08:53:37] httpcore.http11 - send_request_body.started request=<Request [b'GET']>
DEBUG [2026-09-21 08:53:37] httpcore.http11 - send_request_body.complete
DEBUG [2026-09-21 08:53:37] httpcore.http11 - receive_response_headers.started request=<Request [b'GET']>
DEBUG [2026-09-21 08:53:37] httpcore.http11 - receive_response_headers.complete return_value=(b'HTTP/1.1', 302, b'Found', [(b'Cache-Control', b'no-store, no-cache'), (b'Content-Type', b'application/octet-stream'), (b'Location', b'<link to the download location>'), (b'Strict-Transport-Security', b'max-age=31536000'), (b'request-id', b'44de6ff3-71fc-42e6-ad10-9670be4fcb0d'), (b'client-request-id', b'44de6ff3-71fc-42e6-ad10-9670be4fcb0d'), (b'x-ms-ags-diagnostic', b'{"ServerInfo":{"DataCenter":"North Europe","Slice":"E","Ring":"4","ScaleUnit":"001","RoleInstance":"DU2PEPF000107E5"}}'), (b'SPLogId', b'89553da2-e00b-3001-531f-268400ba5220'), (b'Date', b'Mon, 21 Sep 2026 08:53:37 GMT'), (b'Content-Length', b'0')])
INFO [2026-09-21 08:53:37] httpx - HTTP Request: GET https://graph.microsoft.com/v1.0//drives/<drive-id/items/<item-id>/content "HTTP/1.1 302 Found"
DEBUG [2026-09-21 08:53:37] httpcore.http11 - receive_response_body.started request=<Request [b'GET']>
DEBUG [2026-09-21 08:53:37] httpcore.http11 - receive_response_body.complete
DEBUG [2026-09-21 08:53:37] httpcore.http11 - response_closed.started
DEBUG [2026-09-21 08:53:37] httpcore.http11 - response_closed.complete
<END OF LOGS>

Even explicit setting the direct option when creating the various clients has no impact. i.e. if I do the following before making the call, the same error occurs.

auth_provider = AzureIdentityAuthenticationProvider(...)
client = GraphClientFactory.create_with_default_middleware(options=graph_request_adapter.options | {kioo.RedirectHandlerOption.get_key(): kioo.RedirectHandlerOption(should_redirect=True)})
adapter = msg.graph_request_adapter.GraphRequestAdapter(auth_provider, client=client)
ctx = msg.graph_service_client.GraphServiceClient(request_adapter=adapter)
...

I think this issue was caused by commit d9180bb. Tagging @rksharma-owg for visibility.

Dominant language
Python
Stars
31
Forks
39
Avg merge
13h 21m
Merged PRs (30d)
46

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 microsoft/kiota-python

All issues in microsoft/kiota-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.