{"record":{"id":"1c6f1c1f1bfbe12b","repo":"iflytek/astron-agent","slug":"response-data-message","errorCode":null,"errorMessage":"response.data.message","messagePattern":"response\\.data\\.message","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"console/frontend/src/services/login.ts","lineNumber":26,"sourceCode":"  [key: string]: unknown;\n}\n\n/**\n * 插件验证\n */\nexport async function plugValidate(): Promise<AxiosResponse> {\n  return http.get('/xingchen-api/plug/validate');\n}\n\n/**\n * @description: 用户登出\n * @return {*}\n */\n\nexport async function logOutAPI(): Promise<AxiosResponse> {\n  const response = await http.get('/api/v1/auth/userLogout');\n  if (response?.data?.code !== 0) {\n    throw new Error(response.data.message);\n  }\n  return response.data.data;\n}\n\nexport async function getUserInfoMe(): Promise<User> {\n  const response: User = await http.get('/user-info/me');\n  return response;\n}\n","sourceCodeStart":8,"sourceCodeEnd":35,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/frontend/src/services/login.ts#L8-L35","documentation":"logOutAPI calls GET /api/v1/auth/userLogout and throws Error(response.data.message) when the business code is not 0. The thrown message is whatever non-success message the backend returned — a standard application-level error propagation for logout failure.","triggerScenarios":"The logout endpoint returns code !== 0 — e.g. the session/token is already invalid or expired server-side, the auth service is down, or response.data is an HTML error page so message is undefined.","commonSituations":"Expired Casdoor session where logout is called during the token-refresh failure path; gateway 502 rendered as non-zero code; double logout (second call finds no session and errors); backend deployments where the auth route version changed.","solutions":["Treat logout failures as non-fatal: catch the error, clear local auth state (tokens, stores) anyway, and redirect to login.","Inspect response.data.code/message from the network tab to identify the backend's specific failure reason.","Confirm the /api/v1/auth/userLogout route exists in the deployed backend version.","Add a fallback message when response.data.message is missing: response.data.message || '退出登录失败'."],"exampleFix":"// before\nconst response = await http.get('/api/v1/auth/userLogout');\nif (response?.data?.code !== 0) {\n  throw new Error(response.data.message);\n}\n// after\ntry {\n  const response = await http.get('/api/v1/auth/userLogout');\n  if (response?.data?.code !== 0) {\n    console.warn('logout failed:', response.data.message);\n  }\n} finally {\n  userStore.clearTokens();\n  window.location.href = '/login';\n}","handlingStrategy":"try-catch","validationCode":"// only attempt logout with a live session\nif (!userStore.hasToken()) {\n  window.location.href = '/login';\n  return;\n}","typeGuard":"function hasMessage(d: any): d is { code: number; message: string } {\n  return !!d && typeof d.message === 'string' && d.message.length > 0;\n}","tryCatchPattern":"try {\n  await logOutAPI();\n} catch (e: any) {\n  console.warn('logout API failed:', e?.message);\n} finally {\n  userStore.clear();\n  window.location.href = '/login';\n}","preventionTips":["Treat logout as best-effort: always clear local auth state regardless of API result","Guard against double-logout by disabling the button while in flight","Check backend route/version availability when auth behavior changes after deploy","Provide fallback text when response.data.message is missing"],"tags":["auth","logout","api","error-handling"],"backgroundTag":"api-error-response","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}