HKUDS/DeepTutor · error · RuntimeError

{output.strip() or "CodeBuddy did not return an account mode

Error message

{output.strip() or "CodeBuddy did not return an account model catalog."}

What it means

The CLI subprocess ran but its output contained no `- model-name` entries after the 'supported models for your account:' marker, so the regex extracted nothing and the provider raises RuntimeError with the CLI's combined stdout/stderr (or a fallback message). The CLI output usually reveals the real cause: not signed in, auth expired, or an error message.

Source

Thrown at deeptutor/services/llm/provider_core/codebuddy_provider.py:831

    env = os.environ.copy()
    if api_key:
        env[_CODEBUDDY_API_KEY_ENV] = api_key
    process = await asyncio.create_subprocess_exec(
        *command,
        stdin=asyncio.subprocess.DEVNULL,
        stdout=asyncio.subprocess.PIPE,
        stderr=asyncio.subprocess.PIPE,
        env=env,
        **process_kwargs,
    )
    stdout, stderr = await process.communicate()
    output = (stdout + b"\n" + stderr).decode("utf-8", errors="replace")
    marker = "supported models for your account:"
    catalog = output.lower().split(marker, 1)[-1] if marker in output.lower() else ""
    models = re.findall(r"(?m)^\s*-\s+([A-Za-z0-9][A-Za-z0-9._-]*)\s*$", catalog)
    if not models:
        raise RuntimeError(output.strip() or "CodeBuddy did not return an account model catalog.")
    return list(dict.fromkeys(models))


__all__ = [
    "CodeBuddyProvider",
    "DEFAULT_CODEBUDDY_MODEL",
    "fetch_codebuddy_models",
]

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Run `codebuddy --print . --model ...` manually and read the captured output (it's embedded in the exception message) to see the actual CLI error.
  2. Sign in: run the CodeBuddy login flow, then retry the sync.
  3. If output format changed after a CLI update, pin/upgrade to a CLI version whose catalog format matches the parser.

Example fix

# before
# not signed in
await fetch_codebuddy_models()  # RuntimeError with CLI 'please sign in' output

# after
# terminal
$ codebuddy login
await fetch_codebuddy_models()
Defensive patterns

Strategy: try-catch

Validate before calling

import shutil
if not (shutil.which("codebuddy") or shutil.which("cbc")):
    raise RuntimeError("CodeBuddy CLI is required to sync account models.")

Try / catch

try:
    models = await fetch_codebuddy_models()
except RuntimeError as e:
    logger.error("CLI output: %s", e)  # message contains the CLI stdout/stderr
    if "sign" in str(e).lower():
        # re-authenticate and retry once
        models = await fetch_codebuddy_models()
    else:
        raise

Prevention

When it happens

Trigger: Running fetch_codebuddy_models() while the CodeBuddy account isn't authenticated (CLI prints a login prompt instead of a catalog); CLI version changed its output format so the marker/regex no longer match; CLI emitted an error to stderr.

Common situations: Fresh CLI install without `codebuddy login`; long-running servers whose stored session expired; CLI output-format changes after an update breaking the parser.

Related errors


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/625a19916fb6f81b. Report an issue: GitHub.