{"record":{"id":"ac906d8a63cddbf7","repo":"HKUDS/DeepTutor","slug":"sign-in-hint","errorCode":null,"errorMessage":"{_SIGN_IN_HINT}","messagePattern":"\\{_SIGN_IN_HINT\\}","errorType":"error_code","errorClass":"CodeBuddyAuthUnavailable","httpStatus":null,"severity":"error","filePath":"deeptutor/services/llm/provider_core/codebuddy_http_provider.py","lineNumber":92,"sourceCode":"        if self._explicit_api_key:\n            self._apply_token(self._explicit_api_key)\n\n    def get_default_model(self) -> str:\n        return self.default_model or DEFAULT_CODEBUDDY_MODEL\n\n    def _apply_token(self, token: str) -> None:\n        self.api_key = token\n        self._client.api_key = token\n\n    async def _ensure_auth(self, *, reload_from_disk: bool = False) -> None:\n        if self._explicit_api_key:\n            return\n\n        credentials = self._credentials\n        if reload_from_disk or credentials is None:\n            credentials = load_credentials() or credentials\n        if credentials is None:\n            raise CodeBuddyAuthUnavailable(_SIGN_IN_HINT)\n\n        if credentials.is_expired():\n            credentials = await refresh_credentials(credentials)\n\n        base = credentials.api_base\n        if base != str(self._client.base_url).rstrip(\"/\"):\n            self._client.base_url = base\n            self.api_base = base\n        self._credentials = credentials\n        self._apply_token(credentials.access_token)\n\n    async def _chat_impl(\n        self,\n        messages: list[dict[str, Any]],\n        tools: list[dict[str, Any]] | None,\n        model: str | None,\n        max_tokens: int,\n        temperature: float,","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/llm/provider_core/codebuddy_http_provider.py#L74-L110","documentation":"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.","triggerScenarios":"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.","commonSituations":"Fresh installs, containers/CI without a credentials volume, credential files wiped by cache cleanup, or a logged-out state after token revocation.","solutions":["Run the CodeBuddy sign-in flow to persist credentials, then retry.","In CI/containers, mount or copy the credentials file the provider expects (check load_credentials()'s path).","Catch CodeBuddyAuthUnavailable and fall back to another provider or prompt the user to authenticate."],"exampleFix":"# before\nresp = await http_provider.chat(messages)\n\n# after\ntry:\n    resp = await http_provider.chat(messages)\nexcept CodeBuddyAuthUnavailable:\n    raise SystemExit(_SIGN_IN_HINT)  # or trigger interactive sign-in","handlingStrategy":"type-guard","validationCode":"from deeptutor.services.llm.provider_core.codebuddy_http_provider import load_credentials\nif load_credentials() is None:\n    raise SystemExit(\"Please sign in to CodeBuddy before using the HTTP provider\")","typeGuard":"def codebuddy_authenticated() -> bool:\n    try:\n        from deeptutor.services.llm.provider_core.codebuddy_http_provider import load_credentials\n        creds = load_credentials()\n        return creds is not None and not creds.is_expired()\n    except Exception:\n        return False","tryCatchPattern":"from deeptutor.services.llm.provider_core.codebuddy_http_provider import CodeBuddyAuthUnavailable\ntry:\n    resp = await provider.chat(messages)\nexcept CodeBuddyAuthUnavailable:\n    # prompt user to sign in or switch provider — do NOT retry blindly\n    raise","preventionTips":["Run the sign-in flow during environment provisioning.","Check codebuddy_authenticated() at startup before enabling the HTTP provider.","In CI, inject credentials via a mounted secret file and refresh before expiry."],"tags":["codebuddy","auth","credentials","not-signed-in"],"backgroundTag":"missing-credentials","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}