# Buggy code
def check_release_on_github(app):
    # Check if repo remote is on github
    from subprocess import CalledProcessError

    try:
        remote_url = subprocess.check_output(
            "cd ../apps/{} && git ls-remote --get-url".format(app), shell=True
        ).decode()
    except CalledProcessError:
        # Passing this since some apps may not have git initializaed in them
        return None

    if isinstance(remote_url, bytes):
        remote_url = remote_url.decode()

    if "github.com" not in remote_url:
        return None

    # Get latest version from github
    if "https" not in remote_url:
        return None

    org_name = remote_url.split("/")[3]
    r = requests.get(
        "https://api.github.com/repos/{}/{}/releases".format(org_name, app)
    )
    if r.ok:
        lastest_non_beta_release = parse_latest_non_beta_release(r.json())
        return Version(lastest_non_beta_release), org_name
    # In case of an improper response or if there are no releases
    return None


# Traceback (ValueError)
{'method_name': 'frappe.utils.change_log.check_for_update', 'log': <function log at 0x7f837e01f730>, 'retry': 0, 'is_async': True, 'user': 'Administrator', 'kwargs': {}, 'job_name': 'frappe.utils.change_log.check_for_update', 'event': 'daily_long', 'method': <function check_for_update at 0x7f837e54cae8>, 'site': 'my.erp.com'}
Traceback (most recent call last):
File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 102, in execute_job
method(**kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/change_log.py", line 144, in check_for_update
app_details = check_release_on_github(app)
File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/change_log.py", line 207, in check_release_on_github
return Version(lastest_non_beta_release), org_name
File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/semantic_version/base.py", line 102, in __init__
raise ValueError("Call either Version('1.2.3') or Version(major=1, ...).")
ValueError: Call either Version('1.2.3') or Version(major=1, ...).

# Fixed code
def check_release_on_github(app: str):
    """
    Check the latest release for a given Frappe application hosted on Github.

    Args:
            app (str): The name of the Frappe application.

    Returns:
            tuple(Version, str): The semantic version object of the latest release and the
                    organization name, if the application exists, otherwise None.
    """

    from giturlparse import parse
    from giturlparse.parser import ParserError

    try:
        # Check if repo remote is on github
        remote_url = subprocess.check_output(
            "cd ../apps/{} && git ls-remote --get-url".format(app), shell=True
        )
    except subprocess.CalledProcessError:
        # Passing this since some apps may not have git initialized in them
        return

    if isinstance(remote_url, bytes):
        remote_url = remote_url.decode()

    try:
        parsed_url = parse(remote_url)
    except ParserError:
        # Invalid URL
        return

    if parsed_url.resource != "github.com":
        return

    owner = parsed_url.owner
    repo = parsed_url.name

    # Get latest version from GitHub
    r = requests.get(f"https://api.github.com/repos/{owner}/{repo}/releases")
    if r.ok:
        latest_non_beta_release = parse_latest_non_beta_release(r.json())
        if latest_non_beta_release:
            return Version(latest_non_beta_release), owner