Skip to content

Incrementing retries should possibly not pass Response #349

Open

Description

@bjester

suggestion: response is always None at this point, and passing it is the risky part of the plumbing.

It's reset to None at the top of each loop iteration and only assigned on the success path, so the except branch can only ever pass response=None — _should_retry then falls through to response = e.response anyway. That makes the parameter dead.

It's also a duck-typing trap: Retry.increment and retries.sleep expect a urllib3.response.HTTPResponse and call get_redirect_location(), .status, and (on urllib3 1.26, permitted by the new floor) .getheader("Retry-After"). A requests.Response has none of those. Today the truthiness guards short-circuit because all three members of _RETRY_REQUEST_EXCEPTIONS are raised without a response attached — but any future change that surfaces a retryable RequestException carrying one turns a would-be retry into AttributeError, escaping the except MaxRetryError handler as an unrelated error type.

Passing response=None explicitly (the retry decision is already driven entirely by exception type) removes both the dead parameter and the trap.

Originally posted by @rtibblesbot in #348 (comment)

Activity

  1. Mawadda0 commented on Nov 21, 2026

    @Mawadda0

    Hello @bjester , I was looking for an issues to contribute in the community and came across this one.

    After exploring the retry logic in file session.py located in folder morango/sync/, I understand now that the issue might be related to passing a "requests.Response" object to the urllib3's retry methods.

    My understanding is that urllib3 may expect methods or attributes on the response object that are not exist in "requests.Response", which could be the cause of this error.

    If my understanding is true, I'd appreciate it if you could assign me to work on this issue if it's available for contribution.

    Thank you in advance :)

  2. learning-equality-bot commented on Nov 21, 2026

    @learning-equality-bot
    Contributor

    Hi! 👋

    Thanks so much for your interest! This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues. If there are no unassigned 'help wanted' issues available, please wait until new ones are added.

    We really appreciate your willingness to help. 😊

    Are you preparing for Google Summer of Code? See our GSoC guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions