# Buggy code
def _delete_data_from_registry(
    login_server, path, username, password, retry_times=3, retry_interval=5
):
    for i in range(0, retry_times):
        errorMessage = None
        try:
            response = requests.delete(
                "https://{}/{}".format(login_server, path),
                headers=_get_authorization_header(username, password),
            )

            if response.status_code == 200 or response.status_code == 202:
                return
            elif response.status_code == 401 or response.status_code == 404:
                raise CLIError(response.text)
            else:
                raise Exception(response.text)
        except CLIError:
            raise
        except Exception as e:  # pylint: disable=broad-except
            errorMessage = str(e)
            logger.debug("Retrying %s with exception %s", i + 1, errorMessage)
            time.sleep(retry_interval)
    if errorMessage:
        raise CLIError(errorMessage)


# Traceback (AttributeError)
C:\Users\marsma>az acr login --name acr604
'bool' object has no attribute 'rstrip'
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\knack\cli.py", line 193, in invoke
cmd_result = self.invocation.execute(args)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\commands\__init__.py", line 319, in execute
six.reraise(*sys.exc_info())
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\six.py", line 693, in reraise
raise value
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\commands\__init__.py", line 292, in execute
result = cmd(params)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\commands\__init__.py", line 169, in __call__
return super(AzCliCommand, self).__call__(*args, **kwargs)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\knack\commands.py", line 109, in __call__
return self.handler(*args, **kwargs)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\core\__init__.py", line 328, in default_command_handler
result = op(**command_args)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\command_modules\acr\custom.py", line 195, in acr_login
password=password)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\command_modules\acr\_docker_utils.py", line 194, in get_login_credentials
only_refresh_token=True)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\command_modules\acr\_docker_utils.py", line 150, in _get_credentials
password = _get_aad_token(login_server, only_refresh_token, repository, permission)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\azure\cli\command_modules\acr\_docker_utils.py", line 35, in _get_aad_token
login_server = login_server.rstrip('/')
AttributeError: 'bool' object has no attribute 'rstrip'

# Fixed code
def _delete_data_from_registry(
    login_server, path, username, password, retry_times=3, retry_interval=5
):
    for i in range(0, retry_times):
        errorMessage = None
        try:
            response = requests.delete(
                "https://{}{}".format(login_server, path),
                headers=_get_authorization_header(username, password),
            )
            log_registry_response(response)

            if response.status_code == 200 or response.status_code == 202:
                return
            elif response.status_code == 401 or response.status_code == 404:
                raise CLIError(response.text)
            else:
                raise Exception(response.text)
        except CLIError:
            raise
        except Exception as e:  # pylint: disable=broad-except
            errorMessage = str(e)
            logger.debug("Retrying %s with exception %s", i + 1, errorMessage)
            time.sleep(retry_interval)
    if errorMessage:
        raise CLIError(errorMessage)