{"record":{"id":"9e64f348f6042a53","repo":"tonhowtf/omniget","slug":"soundcloud-me-failed","errorCode":null,"errorMessage":"[soundcloud] me failed:","messagePattern":"\\[soundcloud\\] me failed:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/lib/study-music/soundcloud-store.svelte.ts","lineNumber":183,"sourceCode":"\n  async refreshStatus() {\n    try {\n      let s = await pluginInvoke<AuthStatus>(\"study\", \"study:soundcloud:auth:refresh\");\n      this.status = s;\n      if (!s.has_oauth) {\n        const hydrated = await this.tryHydrateFromCookieManager();\n        if (hydrated) {\n          s = await pluginInvoke<AuthStatus>(\"study\", \"study:soundcloud:auth:refresh\");\n          this.status = s;\n        }\n      }\n      if (s.has_oauth && s.user_id == null) {\n        try {\n          const me = await pluginInvoke<any>(\"study\", \"study:soundcloud:me\");\n          this.profile = mapUser(me);\n          if (this.profile) this.status = { ...this.status, user_id: this.profile.id };\n        } catch (e) {\n          console.warn(\"[soundcloud] me failed:\", e);\n        }\n      } else if (s.user_id) {\n        try {\n          const me = await pluginInvoke<any>(\"study\", \"study:soundcloud:me\");\n          this.profile = mapUser(me);\n        } catch {\n          /* ignore */\n        }\n      }\n    } catch (e) {\n      this.error = e instanceof Error ? e.message : String(e);\n    }\n  }\n\n  async tryHydrateFromCookieManager(): Promise<boolean> {\n    try {\n      const { invoke } = await import(\"@tauri-apps/api/core\");\n      const accounts = await invoke<{ domain: string; accounts: { slug: string }[] }>(","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src/lib/study-music/soundcloud-store.svelte.ts#L165-L201","documentation":"Warning from SoundcloudStore.refreshStatus when fetching the authenticated user's profile via study:soundcloud:me fails while status.has_oauth is true and user_id was null. Status flags remain, but this.profile stays unset and user_id is not backfilled, so UI may show a partially-authenticated state.","triggerScenarios":"refreshStatus (triggered by loginWithWebview or logout) detecting has_oauth cookies but the study:soundcloud:me call rejecting — expired/invalid OAuth cookies, SoundCloud API 401/403, or network failure.","commonSituations":"SoundCloud session expired between logins; cookies present but revoked server-side; offline or SoundCloud API outage; bot/abuse protection returning 403 to the /me endpoint.","solutions":["Re-authenticate via loginWithWebview to obtain fresh OAuth cookies","Check network connectivity and SoundCloud API status","Inspect the caught error: 401 means cookies are stale — clear them and log in again","Retry refreshStatus after a transient network/API failure"],"exampleFix":"// before\nconsole.warn(\"[soundcloud] me failed:\", e);\n// after\nconsole.warn(\"[soundcloud] me failed:\", e);\nif (isAuthError(e)) { await this.clearOAuthCookies(); this.status = { ...this.status, has_oauth: false }; }","handlingStrategy":"try-catch","validationCode":"if (!status.has_oauth) return; // nothing to refresh","typeGuard":"function looksLikeScUser(v: unknown): v is { id: string; username?: string; avatar_url?: string } { return typeof v === \"object\" && v !== null && typeof (v as any).id === \"string\"; }","tryCatchPattern":"try { const me = await pluginInvoke<any>(\"study\", \"study:soundcloud:me\"); this.profile = mapUser(me); } catch (e) { console.warn(\"[soundcloud] me failed:\", e); if (isUnauthorized(e)) await this.logout(); }","preventionTips":["Treat has_oauth cookies as untrusted until /me succeeds","Prompt re-login on 401/403 instead of silently keeping a half-authenticated state","Check SoundCloud API status on repeated failures","Refresh status only when network is available"],"tags":["soundcloud","oauth","network"],"backgroundTag":"oauth-token-exchange-failed","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}