# Buggy code
def _obtain_data_from_registry(
    login_server,
    path,
    username,
    password,
    result_index,
    retry_times=3,
    retry_interval=5,
    pagination=20,
):
    resultList = []
    executeNextHttpCall = True

    while executeNextHttpCall:
        executeNextHttpCall = False
        for i in range(0, retry_times):
            errorMessage = None
            try:
                response = requests.get(
                    "https://{}/{}".format(login_server, path),
                    headers=_get_authorization_header(username, password),
                    params=_get_pagination_params(pagination),
                )

                if response.status_code == 200:
                    result = response.json()[result_index]
                    if result:
                        resultList += response.json()[result_index]
                    if "link" in response.headers and response.headers["link"]:
                        linkHeader = response.headers["link"]
                        # The registry is telling us there's more items in the list,
                        # and another call is needed. The link header looks something
                        # like `Link: </v2/_catalog?last=hello-world&n=1>; rel="next"`
                        # we should follow the next path indicated in the link header
                        path = linkHeader[
                            (linkHeader.index("<") + 1) : linkHeader.index(">")
                        ]
                        executeNextHttpCall = True
                    break
                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)

    return resultList


# 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 _obtain_data_from_registry(
    login_server,
    path,
    username,
    password,
    result_index,
    retry_times=3,
    retry_interval=5,
    pagination=20,
):
    resultList = []
    executeNextHttpCall = True

    while executeNextHttpCall:
        executeNextHttpCall = False
        for i in range(0, retry_times):
            errorMessage = None
            try:
                response = requests.get(
                    "https://{}{}".format(login_server, path),
                    headers=_get_authorization_header(username, password),
                    params=_get_pagination_params(pagination),
                )
                log_registry_response(response)

                if response.status_code == 200:
                    result = response.json()[result_index]
                    if result:
                        resultList += response.json()[result_index]
                    if "link" in response.headers and response.headers["link"]:
                        linkHeader = response.headers["link"]
                        # The registry is telling us there's more items in the list,
                        # and another call is needed. The link header looks something
                        # like `Link: </v2/_catalog?last=hello-world&n=1>; rel="next"`
                        # we should follow the next path indicated in the link header
                        path = linkHeader[
                            (linkHeader.index("<") + 1) : linkHeader.index(">")
                        ]
                        executeNextHttpCall = True
                    break
                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)

    return resultList