# Buggy code
def validate_config_against_schema(
    config_schema, config_object, config_path, pack_name=None
):
    """
    Validate provided config dictionary against the provided config schema
    dictionary.
    """
    # NOTE: Lazy improt to avoid performance overhead of importing this module when it's not used
    import jsonschema

    pack_name = pack_name or "unknown"

    schema = util_schema.get_schema_for_resource_parameters(
        parameters_schema=config_schema, allow_additional_properties=True
    )
    instance = config_object

    try:
        cleaned = util_schema.validate(
            instance=instance,
            schema=schema,
            cls=util_schema.CustomValidator,
            use_default=True,
            allow_default_none=True,
        )
    except jsonschema.ValidationError as e:
        attribute = getattr(e, "path", [])
        attribute = ".".join(attribute)

        msg = 'Failed validating attribute "%s" in config for pack "%s" (%s): %s' % (
            attribute,
            pack_name,
            config_path,
            str(e),
        )
        raise jsonschema.ValidationError(msg)

    return cleaned


# Traceback (TypeError)
Traceback (most recent call last):
File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/router.py", line 472, in __call__
resp = func(**kw)
File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2api/controllers/v1/pack_configs.py", line 107, in put
config_api.validate(validate_against_schema=True)
File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/models/api/pack.py", line 274, in validate
cleaned_values = self._validate_config_values_against_schema()
File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/models/api/pack.py", line 296, in _validate_config_values_against_schema
pack_name=self.pack)
File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/util/pack.py", line 111, in validate_config_against_schema
attribute = '.'.join(attribute)
TypeError: sequence item 1: expected string or Unicode, int found
2018-06-06 14:24:35,673 139995931735056 ERROR error_handling [-] API call failed: sequence item 1: expected string or Unicode, int found
Traceback (most recent call last):

# Fixed code
def validate_config_against_schema(
    config_schema, config_object, config_path, pack_name=None
):
    """
    Validate provided config dictionary against the provided config schema
    dictionary.
    """
    # NOTE: Lazy improt to avoid performance overhead of importing this module when it's not used
    import jsonschema

    pack_name = pack_name or "unknown"

    schema = util_schema.get_schema_for_resource_parameters(
        parameters_schema=config_schema, allow_additional_properties=True
    )
    instance = config_object

    try:
        cleaned = util_schema.validate(
            instance=instance,
            schema=schema,
            cls=util_schema.CustomValidator,
            use_default=True,
            allow_default_none=True,
        )
    except jsonschema.ValidationError as e:
        attribute = getattr(e, "path", [])

        if isinstance(attribute, (tuple, list, collections.Iterable)):
            attribute = [str(item) for item in attribute]
            attribute = ".".join(attribute)
        else:
            attribute = str(attribute)

        msg = 'Failed validating attribute "%s" in config for pack "%s" (%s): %s' % (
            attribute,
            pack_name,
            config_path,
            str(e),
        )
        raise jsonschema.ValidationError(msg)

    return cleaned