iflytek/astron-agent · warning · Error

response.data.message

Error message

response.data.message

What it means

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.

Solutions

  1. Treat logout failures as non-fatal: catch the error, clear local auth state (tokens, stores) anyway, and redirect to login.
  2. Inspect response.data.code/message from the network tab to identify the backend's specific failure reason.
  3. Confirm the /api/v1/auth/userLogout route exists in the deployed backend version.
  4. Add a fallback message when response.data.message is missing: response.data.message || '退出登录失败'.

Example fix

// before
const response = await http.get('/api/v1/auth/userLogout');
if (response?.data?.code !== 0) {
  throw new Error(response.data.message);
}
// after
try {
  const response = await http.get('/api/v1/auth/userLogout');
  if (response?.data?.code !== 0) {
    console.warn('logout failed:', response.data.message);
  }
} finally {
  userStore.clearTokens();
  window.location.href = '/login';
}
Defensive patterns

Strategy: try-catch

Validate before calling

// only attempt logout with a live session
if (!userStore.hasToken()) {
  window.location.href = '/login';
  return;
}

Type guard

function hasMessage(d: any): d is { code: number; message: string } {
  return !!d && typeof d.message === 'string' && d.message.length > 0;
}

Try / catch

try {
  await logOutAPI();
} catch (e: any) {
  console.warn('logout API failed:', e?.message);
} finally {
  userStore.clear();
  window.location.href = '/login';
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/1c6f1c1f1bfbe12b. Report an issue: GitHub.

Appendix: source

Thrown at console/frontend/src/services/login.ts:26

  [key: string]: unknown;
}

/**
 * 插件验证
 */
export async function plugValidate(): Promise<AxiosResponse> {
  return http.get('/xingchen-api/plug/validate');
}

/**
 * @description: 用户登出
 * @return {*}
 */

export async function logOutAPI(): Promise<AxiosResponse> {
  const response = await http.get('/api/v1/auth/userLogout');
  if (response?.data?.code !== 0) {
    throw new Error(response.data.message);
  }
  return response.data.data;
}

export async function getUserInfoMe(): Promise<User> {
  const response: User = await http.get('/user-info/me');
  return response;
}

View on GitHub (pinned to 5e758547a8)