{"record":{"id":"e2f89b2008fbadfe","repo":"m1k1o/neko","slug":"session-not-found","errorCode":null,"errorMessage":"session not found","messagePattern":"session not found","errorType":"error_code","errorClass":"ErrSessionNotFound","httpStatus":null,"severity":"error","filePath":"server/pkg/types/session.go","lineNumber":10,"sourceCode":"package types\n\nimport (\n\t\"errors\"\n\t\"net/http\"\n\t\"time\"\n)\n\nvar (\n\tErrSessionNotFound         = errors.New(\"session not found\")\n\tErrSessionAlreadyExists    = errors.New(\"session already exists\")\n\tErrSessionAlreadyConnected = errors.New(\"session is already connected\")\n\tErrSessionLoginDisabled    = errors.New(\"session login disabled\")\n\tErrSessionLoginsLocked     = errors.New(\"session logins locked\")\n)\n\ntype Cursor struct {\n\tX int `json:\"x\"`\n\tY int `json:\"y\"`\n}\n\ntype SessionProfile struct {\n\tId      string\n\tToken   string\n\tProfile MemberProfile\n}\n\ntype SessionState struct {","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/m1k1o/neko/blob/b0f01cedea68893e85a3fd852c0521238c285695/server/pkg/types/session.go#L1-L28","documentation":"ErrSessionNotFound is a sentinel error in the neko types package indicating that a session referenced by id or token does not exist in the session manager. It is returned by Logout, UpdateProfile, sessionsDelete, sessionsDisconnect, Delete, and Authenticate when the session token/cookie or id cannot be resolved to a live session.","triggerScenarios":"Authenticate(r) with a missing/expired/invalid session cookie or token; Logout or Delete with an id for a session that already ended; UpdateProfile or sessionsDisconnect for a disconnected/cleaned-up session.","commonSituations":"Server restart wiping in-memory sessions while clients keep old tokens; session expiry or websocket disconnect cleanup removing the session; load balancer routing to a different neko instance than the one holding the session; cookie misconfiguration (wrong domain/path) so the token never reaches the server.","solutions":["Re-authenticate to obtain a fresh session (login again) and retry the operation.","Verify the client is sending a valid, current session token/cookie to the same server instance that created it.","Check that a reverse proxy/LB uses sticky sessions or shared session storage if running multiple instances.","Confirm session cleanup (disconnect/heartbeat timeouts) isn't removing sessions prematurely.","Clear stale cookies and re-login to avoid old tokens being rejected."],"exampleFix":"// before\nsession, err := sessions.Authenticate(r)\nhandle(session) // nil session, error ignored\n// after\nsession, err := sessions.Authenticate(r)\nif errors.Is(err, types.ErrSessionNotFound) {\n    // redirect client to login flow to mint a new session\n    http.Redirect(w, r, \"/login\", http.StatusUnauthorized)\n    return\n}","handlingStrategy":"validation","validationCode":"// validate the token/cookie resolves before calling APIs\nif token == \"\" {\n    return errors.New(\"no session token provided\")\n}\nif _, ok := sessions.GetByToken(token); !ok {\n    return errors.New(\"session expired, please re-login\")\n}","typeGuard":"func SessionAlive(s types.SessionManager, id string) bool {\n    _, ok := s.Get(id)\n    return ok\n}","tryCatchPattern":"session, err := sessions.Authenticate(r)\nif errors.Is(err, types.ErrSessionNotFound) {\n    http.Error(w, \"session expired\", http.StatusUnauthorized)\n    return\n}\nreturn err","preventionTips":["Refresh sessions/heartbeat before they expire.","Use sticky sessions or shared session state behind load balancers.","Clear cookies after server restarts if sessions are in-memory.","Handle 401 centrally by redirecting to login."],"tags":["session","auth","not-found","go"],"backgroundTag":"session-not-found","analyzedSha":"b0f01cedea68893e85a3fd852c0521238c285695","analyzedAt":"2026-09-01T10:35:56.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}