{"record":{"id":"f9e8028d0ce886f3","repo":"tonhowtf/omniget","slug":"soundcloud-hydrate-from-cookie-manager-failed","errorCode":null,"errorMessage":"[soundcloud] hydrate from cookie manager failed:","messagePattern":"\\[soundcloud\\] hydrate from cookie manager failed:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/lib/study-music/soundcloud-store.svelte.ts","lineNumber":216,"sourceCode":"  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 }[] }>(\n        \"cookies_accounts_for_url\",\n        { url: \"https://soundcloud.com/\" }\n      );\n      if (!accounts.accounts.length) return false;\n      const slug = accounts.accounts[0].slug;\n      const cookies = await invoke<\n        { name: string; value: string; domain: string; path: string }[]\n      >(\"cookies_read_as_json\", { request: { domain: accounts.domain, slug } });\n      if (!cookies.length) return false;\n      await pluginInvoke(\"study\", \"study:soundcloud:auth:set_cookies\", {\n        cookies_json: JSON.stringify(cookies),\n      });\n      return true;\n    } catch (e) {\n      console.warn(\"[soundcloud] hydrate from cookie manager failed:\", e);\n      return false;\n    }\n  }\n\n  async logout() {\n    try {\n      await pluginInvoke(\"study\", \"study:soundcloud:auth:logout\");\n    } finally {\n      this.profile = null;\n      this.likedTracks = [];\n      this.playlists = [];\n      this.followings = [];\n      this.streamFeed = [];\n      this.status = { has_client_id: this.status.has_client_id, has_oauth: false, user_id: null };\n      this.error = null;\n      await this.refreshStatus();\n    }\n  }","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src/lib/study-music/soundcloud-store.svelte.ts#L198-L234","documentation":"Warning from SoundcloudStore.tryHydrateFromCookieManager: cookies were read from the system cookie manager but pushing them to the backend via study:soundcloud:auth:set_cookies failed. The method returns false, so the store treats hydration as not-done and the user must log in via webview.","triggerScenarios":"Calling hydrated()/tryHydrateFromCookieManager at startup when the set_cookies IPC call rejects — plugin backend unavailable, malformed cookies_json payload, or the backend rejecting the cookie set.","commonSituations":"Cookie manager returns cookies in an unexpected shape (schema drift) causing backend validation failure; plugin not started yet during early startup; native webview cookie store permission issues.","solutions":["Ensure the study plugin backend is initialized before hydration runs","Validate/normalize the cookie objects before JSON.stringify so the backend accepts cookies_json","Fall back to interactive loginWithWebview when hydration returns false (already the designed path)","Check backend logs for why set_cookies rejected the payload"],"exampleFix":"// before\nawait pluginInvoke(\"study\", \"study:soundcloud:auth:set_cookies\", { cookies_json: JSON.stringify(cookies) });\n// after\nconst normalized = cookies.filter(isValidScCookie).map(({ name, value, domain, path, expires, secure }) => ({ name, value, domain, path, expires, secure }));\nif (!normalized.length) return false;\nawait pluginInvoke(\"study\", \"study:soundcloud:auth:set_cookies\", { cookies_json: JSON.stringify(normalized) });","handlingStrategy":"fallback","validationCode":"const valid = cookies.every(c => c && typeof c.name === \"string\" && typeof c.value === \"string\"); if (!valid || !cookies.length) return false;","typeGuard":"function isCookieArray(v: unknown): v is Array<{ name: string; value: string; domain?: string; path?: string }> { return Array.isArray(v) && v.every(c => typeof c === \"object\" && c !== null && typeof c.name === \"string\" && typeof c.value === \"string\"); }","tryCatchPattern":"try { const ok = await tryHydrateFromCookieManager(); if (!ok) await loginWithWebview(); } catch (e) { console.warn(\"[soundcloud] hydration failed, falling back to webview login\", e); await loginWithWebview(); }","preventionTips":["Normalize cookie objects to the backend's expected schema before sending","Run hydration only after the plugin backend is ready","Always keep the webview login as the fallback path","Log backend-side set_cookies failures to catch schema drift early"],"tags":["soundcloud","cookies","authentication"],"backgroundTag":"authentication-required","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"}