Repository: oumi-ai/oumi
File: src/oumi/cli/cli_utils.py (Python)

Code before:
        config_content = response.text

        # Validate YAML
        yaml.safe_load(config_content)

        # Save to destination
        if local_path.exists():
            logger.warning(f"Overwriting existing config at {local_path}")
        local_path.parent.mkdir(parents=True, exist_ok=True)

        with open(local_path, "w") as f:
            f.write(config_content)
        logger.info(f"Successfully downloaded config to {local_path}")
    except RequestException as e:
        logger.error(f"Failed to download config from GitHub: {e}")
        raise
    except yaml.YAMLError:
        logger.error("Invalid YAML configuration")
        raise

    return Path(local_path)


def create_github_issue_url(exception: Exception, traceback_str: str) -> str:
    """Create a prefilled GitHub issue URL with comprehensive error details.

    Args:
        exception: The exception that occurred
        traceback_str: The full traceback string

    Returns:
        str: URL for creating a prefilled GitHub issue
    """
    python_version = (
        f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
    )
    system_info = f"{platform.system()} {platform.release()}"

    # Truncate long error messages and tracebacks to avoid URL length limits
    error_msg = (
        str(exception)[:200] + "..." if len(str(exception)) > 200 else str(exception)
    )
    short_traceback = traceback_str.split("\n")[-10:]  # Last 10 lines only
    short_traceback = (
        "\n".join(short_traceback)[:800] + "..."
        if len("\n".join(short_traceback)) > 800
        else "\n".join(short_traceback)
    )

    title = f"CLI Error: {type(exception).__name__}"


Review comment (bug):
Could you also provide an example of a issue that gets generated? How aligned is it with our template: https://github.com/oumi-ai/oumi/issues/new?template=bug-report.yaml

Code after:
        response = requests.get(github_url)
        response.raise_for_status()
        config_content = response.text

        # Validate YAML
        yaml.safe_load(config_content)

        # Save to destination
        if local_path.exists():
            logger.warning(f"Overwriting existing config at {local_path}")
        local_path.parent.mkdir(parents=True, exist_ok=True)

        with open(local_path, "w") as f:
            f.write(config_content)
        logger.info(f"Successfully downloaded config to {local_path}")
    except RequestException as e:
        logger.error(f"Failed to download config from GitHub: {e}")
        raise
    except yaml.YAMLError:
        logger.error("Invalid YAML configuration")
        raise

    return Path(local_path)


def create_github_issue_url(exception: Exception, traceback_str: str) -> str:
    """Create a prefilled GitHub issue URL aligned with the bug report template.

    Args:
        exception: The exception that occurred
        traceback_str: The full traceback string

    Returns:
        str: URL for creating a prefilled GitHub issue
    """
    # 2000 is the max length of a URL to ensure it works with any browser
    MAX_URL_LENGTH = 2000
    base_url = "https://github.com/oumi-ai/oumi/issues/new?"

    python_version = (
        f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
    )
    system_info = f"{platform.system()} {platform.release()}"
    oumi_version = importlib.metadata.version("oumi")
    system_info_content = (
        f"**Please paste the output of `oumi env` here.** "
        f"If you can't run this command, here's basic system info:\n\n"
        f"- Operating system: {system_info}\n"
        f"- Python version: {python_version}\n"
        f"- Oumi version: {oumi_version}"
    )