def CheckEnsureSpecifier(input_api, output_api):
    """Ensure the first specifiers for the builders are valid.
    """
    this_dir = input_api.PresubmitLocalPath()
    builders_json_file = input_api.os_path.join(this_dir,
                                                "builders.json")
    generic_test_expectation = input_api.os_path.join(this_dir,
        '..', '..', '..', '..', 'web_tests', 'TestExpectations')
    if builders_json_file in input_api.AbsoluteLocalPaths():
        with open(generic_test_expectation) as f:
            tags = f.readline().rstrip()
        with open(builders_json_file) as f:
            builders = input_api.json.load(f)
            for key, value in builders.items():
                tag = value["specifiers"][0]
                if tag == "Android" or tag == "Trusty":
                    continue
                if tag not in tags:
                    error_message = (
                        'This CL updates builders.json, but the specifier %s '
                        'is not a valid tag in TestExpectations' % tag)
                    if input_api.is_committing:
                        return [output_api.PresubmitError(error_message)]
                    else:
                        return [output_api.PresubmitPromptWarning(error_message)]
    return []