{"record":{"id":"1d169567339d0eef","repo":"BloopAI/vibe-kanban","slug":"logout-failed-with-status-response-status","errorCode":null,"errorMessage":"Logout failed with status ${response.status}","messagePattern":"Logout failed with status (.+?)","errorType":"http","errorClass":"ApiError","httpStatus":null,"severity":"warning","filePath":"packages/web-core/src/shared/lib/api.ts","lineNumber":1290,"sourceCode":"  },\n\n  localLogin: async (\n    email: string,\n    password: string\n  ): Promise<ProfileResponse> => {\n    const response = await makeRequest('/api/auth/local/login', {\n      method: 'POST',\n      body: JSON.stringify({ email, password }),\n    });\n    return handleApiResponse<ProfileResponse>(response);\n  },\n\n  logout: async (): Promise<void> => {\n    const response = await makeRequest('/api/auth/logout', {\n      method: 'POST',\n    });\n    if (!response.ok) {\n      throw new ApiError(\n        `Logout failed with status ${response.status}`,\n        response.status,\n        response\n      );\n    }\n  },\n\n  /** Returns the current access token for the remote server (auto-refreshes if needed) */\n  getToken: async (): Promise<TokenResponse> => {\n    const response = await makeRequest('/api/auth/token');\n    if (response.status === 401) {\n      throw new ApiError('Unauthorized', 401, response);\n    }\n    return handleApiResponse<TokenResponse>(response);\n  },\n\n  /** Returns the user ID of the currently authenticated user */\n  getCurrentUser: async (): Promise<CurrentUserResponse> => {","sourceCodeStart":1272,"sourceCodeEnd":1308,"githubUrl":"https://github.com/BloopAI/vibe-kanban/blob/4deb7eca8f381f7cbc1f9d15515a9ab8f8009053/packages/web-core/src/shared/lib/api.ts#L1272-L1308","documentation":"oauthApi.logout POSTs /api/auth/logout and throws ApiError('Logout failed with status <code>', status, response) when the response is not OK. Unlike other endpoints it does not call handleApiResponse, so any non-OK status (401, 500, 502) becomes this error; the session cookie may or may not have actually been cleared.","triggerScenarios":"Logging out when POST /api/auth/logout returns non-OK: auth session already invalid/expired server-side (401), backend error while clearing the session (500), or the local backend is down so a proxy error status is returned.","commonSituations":"Session already expired server-side so the logout endpoint rejects the call; backend restarted with new signing keys invalidating old cookies; remote host unreachable during logout; reverse proxy returning 502 when the backend is stopped.","solutions":["Ignore or downgrade the error client-side if status is 401 — the session is already invalid, so clear local state and treat the user as logged out","Clear local auth state (cookies, cached tokens/profile) and redirect to the login screen regardless of server response","Verify the backend is running and reachable if the status is 5xx/502, then retry the logout","Check backend logs for the session-clearing failure if 500 persists"],"exampleFix":"// before\nif (!response.ok) {\n  throw new ApiError(`Logout failed with status ${response.status}`, response.status, response);\n}\n// after\nif (!response.ok && response.status !== 401) {\n  throw new ApiError(`Logout failed with status ${response.status}`, response.status, response);\n}\n// 401 means the session was already gone — proceed with local cleanup either way.","handlingStrategy":"try-catch","validationCode":"// Only attempt logout if a session likely exists\nconst status = await oauthApi.status();\nif (!status.authenticated) return clearLocalAuthState();","typeGuard":"function isLogoutError(e: unknown): e is ApiError & { status: number } {\n  return e instanceof ApiError && e.message.startsWith('Logout failed with status');\n}","tryCatchPattern":"try {\n  await oauthApi.logout();\n} catch (e) {\n  if (isLogoutError(e) && e.status === 401) {\n    // session already gone — treat as logged out\n  } else {\n    showToast('Logout failed on the server; local session cleared anyway');\n  }\n} finally {\n  clearLocalAuthState();\n  navigateToLogin();\n}","preventionTips":["Treat 401 on logout as success (session already invalid) and proceed with local cleanup","Always clear local state in a finally block so the UI never gets stuck logged-in","Check /api/auth/status before logout to skip the call when unauthenticated","Verify backend reachability if 5xx logout failures recur"],"tags":["auth","logout","api-error","http"],"backgroundTag":"logout-request-failed","analyzedSha":"4deb7eca8f381f7cbc1f9d15515a9ab8f8009053","analyzedAt":"2026-08-29T09:24:13.446Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}