Skip to content

RetryPolicy.increment is not robust to response being None #31528

Open

Description

This method:

def increment(self, settings, response=None, error=None):
"""Increment the retry counters.
:param settings: The retry settings.
:type settings: dict
:param response: A pipeline response object.
:type response: ~azure.core.pipeline.PipelineResponse
:param error: An error encountered during the request, or
None if the response was received successfully.
:type error: ~azure.core.exceptions.AzureError
:return: Whether any retry attempt is available
True if more retry attempts available, False otherwise
:rtype: bool
"""

Claims that None for a response is ok, but the code is actually far from being able to deal with that, and the risk that it raises an AttributeError is really high. All usage in azure-core today pass a response object, which makes the issue not obvious unless typing gets involved.

After discussing with @annatisch , I open an issue to consider refactoring this code to be more explicit about None behavior. In the meantime, for typing purposes we will cast the response in the code.

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

Metadata

Assignees

No one assigned

    Labels

    Azure.CoreClientThis issue points to a problem in the data-plane of the library.bugThis issue requires a change to an existing behavior in the product in order to be resolved.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions