HKUDS/DeepTutor · error · CodeBuddyAuthUnavailable

{_SIGN_IN_HINT}

Error message

{_SIGN_IN_HINT}

What it means

The HTTP CodeBuddy provider requires stored credentials; _ensure_auth() tried reloading them from disk and found none, so it raises CodeBuddyAuthUnavailable with a sign-in hint before any HTTP request is made. It's an authentication-prerequisite error, not a network one.

Source

Thrown at deeptutor/services/llm/provider_core/codebuddy_http_provider.py:92

        if self._explicit_api_key:
            self._apply_token(self._explicit_api_key)

    def get_default_model(self) -> str:
        return self.default_model or DEFAULT_CODEBUDDY_MODEL

    def _apply_token(self, token: str) -> None:
        self.api_key = token
        self._client.api_key = token

    async def _ensure_auth(self, *, reload_from_disk: bool = False) -> None:
        if self._explicit_api_key:
            return

        credentials = self._credentials
        if reload_from_disk or credentials is None:
            credentials = load_credentials() or credentials
        if credentials is None:
            raise CodeBuddyAuthUnavailable(_SIGN_IN_HINT)

        if credentials.is_expired():
            credentials = await refresh_credentials(credentials)

        base = credentials.api_base
        if base != str(self._client.base_url).rstrip("/"):
            self._client.base_url = base
            self.api_base = base
        self._credentials = credentials
        self._apply_token(credentials.access_token)

    async def _chat_impl(
        self,
        messages: list[dict[str, Any]],
        tools: list[dict[str, Any]] | None,
        model: str | None,
        max_tokens: int,
        temperature: float,

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Run the CodeBuddy sign-in flow to persist credentials, then retry.
  2. In CI/containers, mount or copy the credentials file the provider expects (check load_credentials()'s path).
  3. Catch CodeBuddyAuthUnavailable and fall back to another provider or prompt the user to authenticate.

Example fix

# before
resp = await http_provider.chat(messages)

# after
try:
    resp = await http_provider.chat(messages)
except CodeBuddyAuthUnavailable:
    raise SystemExit(_SIGN_IN_HINT)  # or trigger interactive sign-in
Defensive patterns

Strategy: type-guard

Validate before calling

from deeptutor.services.llm.provider_core.codebuddy_http_provider import load_credentials
if load_credentials() is None:
    raise SystemExit("Please sign in to CodeBuddy before using the HTTP provider")

Type guard

def codebuddy_authenticated() -> bool:
    try:
        from deeptutor.services.llm.provider_core.codebuddy_http_provider import load_credentials
        creds = load_credentials()
        return creds is not None and not creds.is_expired()
    except Exception:
        return False

Try / catch

from deeptutor.services.llm.provider_core.codebuddy_http_provider import CodeBuddyAuthUnavailable
try:
    resp = await provider.chat(messages)
except CodeBuddyAuthUnavailable:
    # prompt user to sign in or switch provider — do NOT retry blindly
    raise

Prevention

When it happens

Trigger: Calling chat via the CodeBuddy HTTP provider on a machine where `load_credentials()` returns None — user never signed in, credentials file deleted, or first run in a fresh environment.

Common situations: Fresh installs, containers/CI without a credentials volume, credential files wiped by cache cleanup, or a logged-out state after token revocation.

Related errors


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