# Buggy code
def _get_user_business_list(request, use_cache=True):
    """Get authorized business list for a exact username.

    :param object request: django request object.
    :param bool use_cache: (Optional)
    """
    user = request.user
    cache_key = "%s_get_user_business_list_%s" % (CACHE_PREFIX, user.username)
    data = cache.get(cache_key)

    if not (use_cache and data):
        user_info = _get_user_info(request)
        client = get_client_by_request(request)
        result = client.cc.search_business(
            {
                "bk_supplier_account": user_info["bk_supplier_account"],
                "condition": {
                    "bk_data_status": {"$in": ["enable", "disabled", None]},
                    "$or": [
                        {"bk_biz_developer": {"$regex": user.username}},
                        {"bk_biz_productor": {"$regex": user.username}},
                        {"bk_biz_maintainer": {"$regex": user.username}},
                        {"bk_biz_tester": {"$regex": user.username}},
                    ],
                },
            }
        )

        if result["result"]:
            data = result["data"]["info"]
            cache.set(cache_key, data, DEFAULT_CACHE_TIME_FOR_CC)
        elif result.get("code") in ("20101", 20101):
            raise exceptions.Unauthorized(result["message"])
        elif result.get("code") in ("20103", 20103, "20201", 20201, "20202", 20202):
            raise exceptions.Forbidden(result["message"])
        else:
            raise exceptions.APIError(
                "cc", "search_business", result.get("detail_message", result["message"])
            )

    return data


# Traceback (ImportError)
------STARTING: Migrate Database------
Traceback (most recent call last):
File "manage.py", line 27, in <module>
execute_from_command_line(sys.argv)
File "/cache/.bk/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/cache/.bk/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 328, in execute
django.setup()
File "/cache/.bk/env/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/cache/.bk/env/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/cache/.bk/env/lib/python2.7/site-packages/django/apps/config.py", line 112, in create
mod = import_module(mod_path)
File "/cache/.bk/env/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/data/app/code/pipeline/apps.py", line 18, in <module>
from rediscluster import StrictRedisCluster
File "/cache/.bk/env/lib/python2.7/site-packages/rediscluster/__init__.py", line 7, in <module>
from .client import StrictRedisCluster, RedisCluster
File "/cache/.bk/env/lib/python2.7/site-packages/rediscluster/client.py", line 10, in <module>
from .connection import (
File "/cache/.bk/env/lib/python2.7/site-packages/rediscluster/connection.py", line 11, in <module>
from .nodemanager import NodeManager
File "/cache/.bk/env/lib/python2.7/site-packages/rediscluster/nodemanager.py", line 12, in <module>
from redis._compat import b, unicode, bytes, long, basestring
ImportError: cannot import name b
------FAILURE: Migrate Database------

# Fixed code
def _get_user_business_list(request, use_cache=True):
    """Get authorized business list for a exact username.

    :param object request: django request object.
    :param bool use_cache: (Optional)
    """
    user = request.user
    cache_key = "%s_get_user_business_list_%s" % (CACHE_PREFIX, user.username)
    data = cache.get(cache_key)

    if not (use_cache and data):
        user_info = _get_user_info(request)
        client = get_client_by_user(request.user.username)
        result = client.cc.search_business(
            {
                "bk_supplier_account": user_info["bk_supplier_account"],
                "condition": {
                    "bk_data_status": {"$in": ["enable", "disabled", None]},
                    "$or": [
                        {"bk_biz_developer": {"$regex": user.username}},
                        {"bk_biz_productor": {"$regex": user.username}},
                        {"bk_biz_maintainer": {"$regex": user.username}},
                        {"bk_biz_tester": {"$regex": user.username}},
                    ],
                },
            }
        )

        if result["result"]:
            data = result["data"]["info"]
            cache.set(cache_key, data, DEFAULT_CACHE_TIME_FOR_CC)
        elif result.get("code") in ("20101", 20101):
            raise exceptions.Unauthorized(result["message"])
        elif result.get("code") in ("20103", 20103, "20201", 20201, "20202", 20202):
            raise exceptions.Forbidden(result["message"])
        else:
            raise exceptions.APIError(
                "cc", "search_business", result.get("detail_message", result["message"])
            )

    return data