plandex-ai/plandex · warning · http

Error clearing account from cookies:

Error message

Error clearing account from cookies: 

What it means

SignOutHandler reports HTTP 500 at app/server/handlers/sessions.go:276-281 when ClearAccountFromCookies returns an error while removing account-identifying cookies for auth.User.Id. Like the auth-cookie clear, this operates on response headers and fails when headers/body were already written or the helper errors internally.

Source

Thrown at app/server/handlers/sessions.go:280

	if err != nil {
		log.Printf("Error deleting auth token: %v\n", err)
		http.Error(w, "Error deleting auth token: "+err.Error(), http.StatusInternalServerError)
		return
	}

	err = ClearAuthCookieIfBrowser(w, r)

	if err != nil {
		log.Printf("Error clearing auth cookie: %v\n", err)
		http.Error(w, "Error clearing auth cookie: "+err.Error(), http.StatusInternalServerError)
		return
	}

	err = ClearAccountFromCookies(w, r, auth.User.Id)

	if err != nil {
		log.Printf("Error clearing account from cookies: %v\n", err)
		http.Error(w, "Error clearing account from cookies: "+err.Error(), http.StatusInternalServerError)
		return
	}

	log.Println("Successfully signed out")
}

func GetOrgUserConfigHandler(w http.ResponseWriter, r *http.Request) {
	log.Println("Received request for GetOrgUserConfigHandler")

	auth := Authenticate(w, r, true)
	if auth == nil {
		return
	}

	orgUserConfig, err := db.GetOrgUserConfig(auth.User.Id, auth.OrgId)

	if err != nil {
		log.Printf("Error getting org user config: %v\n", err)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check the logged 'Error clearing account from cookies: ...' text for http header-write errors
  2. Verify the clear helper's cookie Name/Path/Domain exactly match those used when the cookie was set
  3. Make sure nothing writes to w before this point in the request lifecycle
  4. Treat as non-fatal: the server-side token is already deleted, so log and continue instead of returning 500

Example fix

// before
err = ClearAccountFromCookies(w, r, auth.User.Id)
if err != nil {
	http.Error(w, "Error clearing account from cookies: "+err.Error(), http.StatusInternalServerError)
	return
}
// after
err = ClearAccountFromCookies(w, r, auth.User.Id)
if err != nil {
	log.Printf("Error clearing account from cookies: %v\n", err) // non-fatal
}
Defensive patterns

Strategy: fallback

Validate before calling

// server-side: confirm cookie attributes match before clearing
const accountCookiePath = "/" // must equal the path used at Set time

Type guard

func cookieExists(r *http.Request, name string) bool {
	_, err := r.Cookie(name)
	return err == nil
}

Try / catch

err := ClearAccountFromCookies(w, r, userID)
if err != nil {
	log.Printf("account cookie clear failed, falling back: %v", err)
	http.SetCookie(w, &http.Cookie{Name: "account", Value: "", Path: "/", MaxAge: -1})
}

Prevention

When it happens

Trigger: Sign-out request where the account-cookie clearing helper fails: response already committed, malformed cookie attributes, or helper-internal failure computing the cookie value for the given user id.

Common situations: Header already sent by earlier middleware, cookie set with a path/domain that the clear call does not match, or cookie names changed in a release so the clear helper no longer matches what was set.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/26ca86f43b492e6d. Report an issue: GitHub.