{"record":{"id":"e967647a7ae62cee","repo":"Molunerfinn/PicGo","slug":"result-error-dynamic-message-propagated-from-rpc-e96764","errorCode":null,"errorMessage":"result.error (dynamic message propagated from RPC failure)","messagePattern":"result\\.error \\(dynamic message propagated from RPC failure\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/renderer/queries/picgo-cloud.ts","lineNumber":13,"sourceCode":"import { useQuery } from '@tanstack/react-query'\nimport { UserPlanLevel, type IPicGoCloudUserInfo } from '#/types/cloud'\nimport { cloudAdapter } from '@/adapters/cloud'\nimport { rendererQueryClient } from './query-client'\n\nexport const PicGoCloudQueryKeys = {\n  userInfo: ['picgo-cloud', 'user-info'] as const\n}\n\nasync function fetchPicGoCloudUserInfo (): Promise<IPicGoCloudUserInfo | null> {\n  const result = await cloudAdapter.getUserInfo({ refresh: true })\n  if (!result.success) {\n    throw new Error(result.error)\n  }\n  return result.data\n}\n\nexport function usePicGoCloudUserInfoQuery () {\n  return useQuery({\n    queryKey: PicGoCloudQueryKeys.userInfo,\n    queryFn: fetchPicGoCloudUserInfo,\n    refetchOnWindowFocus: true\n  })\n}\n\nexport function usePicGoCloudUserInfo () {\n  const query = usePicGoCloudUserInfoQuery()\n  const userInfo = query.data\n\n  return {\n    ...query,","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/Molunerfinn/PicGo/blob/07ec7068a5512344da093d49a8408fa63ba3421e/src/renderer/queries/picgo-cloud.ts#L1-L31","documentation":"fetchPicGoCloudUserInfo throws Error(result.error) when cloudAdapter.getUserInfo({ refresh: true }) returns success:false, forcing a server-side refresh of the PicGo Cloud user profile through the PICGO_CLOUD_GET_USER_INFO RPC. Because many other queries depend on this userInfo, a failure here cascades to dependent hooks like usePicGoCloudUserInfo and useCloudConfigSyncStateQuery.","triggerScenarios":"User info RPC fails with refresh:true: token expired or revoked, picgo-hub unreachable, account frozen/deleted server-side, or handler exception serialized into result.error.","commonSituations":"App start with a stale token (refetchOnWindowFocus triggers refresh); password changed on another device; server maintenance window; offline launch.","solutions":["Inspect query.error.message; if it indicates auth failure, run cloudAdapter.login() to establish a fresh session.","On success of re-login, call invalidatePicGoCloudUserInfoQuery() to retry the fetch.","For transient network errors, rely on refetchOnWindowFocus or manual invalidate.","Treat persistent failure as logged-out state in the UI rather than showing stale profile data.","Add a fallback message if result.error may be undefined (new Error(result.error || '...')) to avoid empty error text."],"exampleFix":"// before\nif (!result.success) {\n  throw new Error(result.error)\n}\n// after\nif (!result.success) {\n  throw new Error(result.error || 'Failed to fetch PicGo Cloud user info')\n}","handlingStrategy":"retry","validationCode":"const token = await getStoredCloudToken()\nif (!token) {\n  // Skip refresh; treat as logged out rather than letting the RPC fail\n  setPicGoCloudUserInfoQueryData(null)\n}","typeGuard":"function isUserInfoSuccess(r: { success: boolean, data?: IPicGoCloudUserInfo | null, error?: string }): r is { success: true, data: IPicGoCloudUserInfo | null } {\n  return r.success === true\n}","tryCatchPattern":"try {\n  await invalidatePicGoCloudUserInfoQuery()\n  const { error } = usePicGoCloudUserInfo()\n  if (error) {\n    await cloudAdapter.login() // re-auth on failure, then invalidate again\n    await invalidatePicGoCloudUserInfoQuery()\n  }\n} catch (e) {\n  toast.error(e instanceof Error ? e.message : 'Cloud login required')\n}","preventionTips":["Configure retry: 1-2 attempts with backoff for this root query since many queries depend on it.","On auth-flavored errors, run the login flow instead of retrying blindly.","Invalidate downstream queries (usage, billing, config-sync) after userInfo recovers.","Treat persistent userInfo failure as logged-out state in the UI."],"tags":["rpc","react-query","authentication","network"],"backgroundTag":"rpc-error-propagation","analyzedSha":"07ec7068a5512344da093d49a8408fa63ba3421e","analyzedAt":"2026-08-30T01:45:22.289Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}