# Buggy code
def rasa_x(args: argparse.Namespace):
    from rasa.cli.utils import print_success, print_error, signal_handler
    from rasa.core.utils import AvailableEndpoints

    signal.signal(signal.SIGINT, signal_handler)

    _configure_logging(args)

    if args.production:
        print_success("Starting Rasa X in production mode... 🚀")

        args.endpoints = get_validated_path(
            args.endpoints, "endpoints", DEFAULT_ENDPOINTS_PATH, True
        )
        endpoints = AvailableEndpoints.read_endpoints(args.endpoints)
        _rasa_service(args, endpoints)
    else:
        if not is_rasa_x_installed():
            print_error(
                "Rasa X is not installed. The `rasa x` "
                "command requires an installation of Rasa X."
            )
            sys.exit(1)

        project_path = "."

        if not is_rasa_project_setup(project_path):
            print_error(
                "This directory is not a valid Rasa project. Use 'rasa init' "
                "to create a new Rasa project or switch to a valid Rasa project "
                "directory."
            )
            sys.exit(1)

        if args.data and not os.path.exists(args.data):
            print_warning(
                "The provided data path ('{}') does not exists. Rasa X will start "
                "without any training data.".format(args.data)
            )

        # noinspection PyUnresolvedReferences
        from rasax.community import local

        local.check_license_and_metrics(args)

        rasa_x_token = generate_rasa_x_token()
        process = start_rasa_for_local_rasa_x(args, rasa_x_token=rasa_x_token)
        try:
            local.main(args, project_path, args.data, token=rasa_x_token)
        finally:
            process.terminate()


# Traceback (AttributeError)
Starting Rasa X in local mode... 🚀
Traceback (most recent call last):
File "/.../.venv/bin/rasa", line 12, in <module>
sys.exit(main())
File "/.../.venv/lib/python3.6/site-packages/rasa/__main__.py", line 70, in main
cmdline_arguments.func(cmdline_arguments)
File "/.../.venv/lib/python3.6/site-packages/rasa/cli/x.py", line 243, in rasa_x
local.main(args, project_path, args.data, token=rasa_x_token)
File "/.../.venv/lib/python3.6/site-packages/rasax/community/local.py", line 194, in main
session)
File "/.../.venv/lib/python3.6/site-packages/rasax/community/local.py", line 144, in _initialize_with_local_data
LOCAL_PROJECT_NAME,
File "/.../.venv/lib/python3.6/site-packages/rasax/community/api/initialise.py", line 170, in inject_domain
username=username)
File "/.../.venv/lib/python3.6/site-packages/rasax/community/services/projects_service.py", line 48, in store_domain
templates = _templates(domain, username, project_id)
File "/.../.venv/lib/python3.6/site-packages/rasax/community/services/projects_service.py", line 259, in _templates
for template, responses in templates.items() for response in responses
File "/.../.venv/lib/python3.6/site-packages/rasax/community/services/projects_service.py", line 259, in <listcomp>
for template, responses in templates.items() for response in responses
AttributeError: 'str' object has no attribute 'get'

# Fixed code
def rasa_x(args: argparse.Namespace):
    from rasa.cli.utils import print_success, print_error, signal_handler
    from rasa.core.utils import AvailableEndpoints

    signal.signal(signal.SIGINT, signal_handler)

    _configure_logging(args)

    if args.production:
        print_success("Starting Rasa X in production mode... 🚀")

        args.endpoints = get_validated_path(
            args.endpoints, "endpoints", DEFAULT_ENDPOINTS_PATH, True
        )
        endpoints = AvailableEndpoints.read_endpoints(args.endpoints)
        _rasa_service(args, endpoints)
    else:
        if not is_rasa_x_installed():
            print_error(
                "Rasa X is not installed. The `rasa x` "
                "command requires an installation of Rasa X."
            )
            sys.exit(1)

        project_path = "."

        if not is_rasa_project_setup(project_path):
            print_error(
                "This directory is not a valid Rasa project. Use 'rasa init' "
                "to create a new Rasa project or switch to a valid Rasa project "
                "directory."
            )
            sys.exit(1)

        _validate_domain(os.path.join(project_path, DEFAULT_DOMAIN_PATH))

        if args.data and not os.path.exists(args.data):
            print_warning(
                "The provided data path ('{}') does not exists. Rasa X will start "
                "without any training data.".format(args.data)
            )

        # noinspection PyUnresolvedReferences
        from rasax.community import local

        local.check_license_and_metrics(args)

        rasa_x_token = generate_rasa_x_token()
        process = start_rasa_for_local_rasa_x(args, rasa_x_token=rasa_x_token)
        try:
            local.main(args, project_path, args.data, token=rasa_x_token)
        except Exception:
            print(traceback.format_exc())
            print_error(
                "Sorry, something went wrong (see error above). Make sure to start "
                "Rasa X with valid data and valid domain and config files. Please, "
                "also check any warnings that popped up.\nIf you need help fixing "
                "the issue visit our forum: https://forum.rasa.com/."
            )
        finally:
            process.terminate()