Task: gitlab.update-multiple-issues-single-repo
Goal: Add a comment "i need someone to take another look at this" to the closed issues about unused vendor dependencies, the Konami code, and offline downloads in the byteblaze/empathy-prompts repository.
Task configuration:
issue_status: closed
topics: unused vendor dependencies, the Konami code, and offline downloads
search_keywords_list: unused vendor dependencies, konami code, offline downloads
namespace: byteblaze
project_name: empathy-prompts
comment: i need someone to take another look at this

Validation code:
from typing import Any, Dict, List
from urllib.parse import quote

import requests
import json
import os

def validate(messages: List[Dict[str, str]], config: Dict[str, Any]) -> int:

    if not messages:
        return 0

    # Check whether we have the necessary information to validate
    if not "namespace" in config or not "project_name" in config:
        raise ValueError("Target must contain 'namespace' and 'project_name'")

    # Build the project id
    project_id = quote(
        f"{config['namespace']}/{config['project_name']}", safe=""
    ).replace(".", "%2E")

    # Build the url
    for search_keywords in config["search_keywords_list"].split(", "):
        search_keywords = search_keywords.strip()
        url = (
            os.getenv("GITLAB_BASE_URL", "").rstrip("/")
            + "/api/v4/projects/"
            + project_id
            + "/issues"
            + "?state="
            + config["issue_status"]
            + "&search="
            + quote(search_keywords, safe="")
            + "&in=title"
        )

        response = requests.request(
            method="GET",
            url=url,
            headers={
                "Content-Type": "application/json",
                "Accept": "application/json",
                **json.loads(os.getenv("GITLAB_EXTRA_HTTP_HEADERS", "{}")),
            },
        )
        if not response.status_code == 200:
            return 0
        result = response.json()
        if len(result) == 0:
            return 0
        issue = result[0]

        # search for notes in the issue
        notes_url = (
            os.getenv("GITLAB_BASE_URL", "").rstrip("/")
            + "/api/v4/projects/"
            + project_id
            + "/issues/"
            + str(issue["iid"])
            + "/notes"
        )
        response = requests.request(
            method="GET",
            url=notes_url,
            headers={
                "Content-Type": "application/json",
                "Accept": "application/json",
                **json.loads(os.getenv("GITLAB_EXTRA_HTTP_HEADERS", "{}")),
            },
        )
        if not response.status_code == 200:
            return 0
        result = response.json()
        if len(result) == 0:
            return 0
        note = result[0]
        if config["comment"].lower().strip() not in note["body"].lower().strip():
            return 0

    return 1

if __name__ == "__main__":
    messages = [{"role": "assistant", "content": "test"}]

    # TODO: implement at least 2 test cases (1 that fails, 1 that passes)
    config = {
        "namespace": "byteblaze",
        "project_name": "gimmiethat.space",
    }
    assert validate(messages, config) == 1

    config = {
        "namespace": "byteblaze",
        "project_name": "unknown_project",
    }
    assert validate(messages, config) == 0