# Buggy code
def _parse_oneof_validator(error):
    """oneOf has multiple schemas, so we need to reason about which schema, sub
    schema or constraint the validation is failing on.
    Inspecting the context value of a ValidationError gives us information about
    which sub schema failed and which kind of error it is.
    """
    types = []
    for context in error.context:
        if context.validator == "oneOf":
            _, error_msg = _parse_oneof_validator(context)
            return path_string(context.path), error_msg

        if context.validator == "required":
            return (None, context.message)

        if context.validator == "additionalProperties":
            invalid_config_key = parse_key_from_error_msg(context)
            return (
                None,
                "contains unsupported option: '{}'".format(invalid_config_key),
            )

        if context.path:
            return (
                path_string(context.path),
                "contains {}, which is an invalid type, it should be {}".format(
                    json.dumps(context.instance),
                    _parse_valid_types_from_validator(context.validator_value),
                ),
            )

        if context.validator == "uniqueItems":
            return (
                None,
                "contains non unique items, please remove duplicates from {}".format(
                    context.instance
                ),
            )

        if context.validator == "type":
            types.append(context.validator_value)

    valid_types = _parse_valid_types_from_validator(types)
    return (None, "contains an invalid type, it should be {}".format(valid_types))


# Traceback (AttributeError)
$ docker-compose -f example.yml build
Traceback (most recent call last):
File "/home/pupssman/venv/py2/bin/docker-compose", line 11, in <module>
sys.exit(main())
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/cli/main.py", line 68, in main
command()
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/cli/main.py", line 118, in perform_command
project = project_from_options('.', options)
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/cli/command.py", line 37, in project_from_options
override_dir=options.get('--project-directory'),
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/cli/command.py", line 91, in get_project
config_data = config.load(config_details)
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/config/config.py", line 368, in load
for config_file in config_details.config_files
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/config/config.py", line 534, in process_config_file
validate_against_config_schema(config_file)
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/config/validation.py", line 393, in validate_against_config_schema
config_file.filename)
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/config/validation.py", line 454, in handle_errors
error_msg = '\n'.join(format_error_func(error) for error in errors)
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/config/validation.py", line 454, in <genexpr>
error_msg = '\n'.join(format_error_func(error) for error in errors)
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/config/validation.py", line 380, in process_config_schema_errors
return handle_generic_error(error, path)
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/config/validation.py", line 252, in handle_generic_error
config_key, error_msg = _parse_oneof_validator(error)
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/config/validation.py", line 335, in _parse_oneof_validator
_parse_valid_types_from_validator(context.validator_value)),
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/config/validation.py", line 300, in _parse_valid_types_from_validator
return anglicize_json_type(validator)
File "/home/pupssman/venv/py2/local/lib/python2.7/site-packages/compose/config/validation.py", line 216, in anglicize_json_type
if json_type.startswith(('a', 'e', 'i', 'o', 'u')):
AttributeError: 'bool' object has no attribute 'startswith'

# Fixed code
def _parse_oneof_validator(error):
    """oneOf has multiple schemas, so we need to reason about which schema, sub
    schema or constraint the validation is failing on.
    Inspecting the context value of a ValidationError gives us information about
    which sub schema failed and which kind of error it is.
    """
    types = []
    for context in error.context:
        if context.validator == "oneOf":
            _, error_msg = _parse_oneof_validator(context)
            return path_string(context.path), error_msg

        if context.validator == "required":
            return (None, context.message)

        if context.validator == "additionalProperties":
            invalid_config_key = parse_key_from_error_msg(context)
            return (
                None,
                "contains unsupported option: '{}'".format(invalid_config_key),
            )

        if context.validator == "uniqueItems":
            return (
                path_string(context.path) if context.path else None,
                "contains non-unique items, please remove duplicates from {}".format(
                    context.instance
                ),
            )

        if context.path:
            return (
                path_string(context.path),
                "contains {}, which is an invalid type, it should be {}".format(
                    json.dumps(context.instance),
                    _parse_valid_types_from_validator(context.validator_value),
                ),
            )

        if context.validator == "type":
            types.append(context.validator_value)

    valid_types = _parse_valid_types_from_validator(types)
    return (None, "contains an invalid type, it should be {}".format(valid_types))