# Buggy code
def validate_domain_yaml(cls, yaml):
    """Validate domain yaml."""
    from pykwalify.core import Core

    log = logging.getLogger("pykwalify")
    log.setLevel(logging.WARN)

    try:
        schema_file = pkg_resources.resource_filename(__name__, "schemas/domain.yml")
        source_data = rasa.utils.io.read_yaml(yaml)
    except YAMLError:
        raise InvalidDomain(
            "The provided domain file is invalid. You can use "
            "http://www.yamllint.com/ to validate the yaml syntax "
            "of your domain file."
        )

    try:
        c = Core(source_data=source_data, schema_files=[schema_file])
        c.validate(raise_exception=True)
    except SchemaError:
        raise InvalidDomain(
            "Failed to validate your domain yaml. "
            "Please make sure the file is correct; to do so, "
            "take a look at the errors logged during "
            "validation previous to this exception. "
            "You can also validate your domain file's yaml "
            "syntax using http://www.yamllint.com/."
        )


# 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 validate_domain_yaml(cls, yaml):
    """Validate domain yaml."""
    from pykwalify.core import Core

    log = logging.getLogger("pykwalify")
    log.setLevel(logging.WARN)

    try:
        schema_file = pkg_resources.resource_filename(__name__, "schemas/domain.yml")
        source_data = rasa.utils.io.read_yaml(yaml)
    except YAMLError:
        raise InvalidDomain(
            "The provided domain file is invalid. You can use "
            "http://www.yamllint.com/ to validate the yaml syntax "
            "of your domain file."
        )
    except DuplicateKeyError as e:
        raise InvalidDomain(
            "The provided domain file contains a duplicated key: {}".format(str(e))
        )

    try:
        c = Core(source_data=source_data, schema_files=[schema_file])
        c.validate(raise_exception=True)
    except SchemaError:
        raise InvalidDomain(
            "Failed to validate your domain yaml. "
            "Please make sure the file is correct; to do so, "
            "take a look at the errors logged during "
            "validation previous to this exception. "
            "You can also validate your domain file's yaml "
            "syntax using http://www.yamllint.com/."
        )