{"record":{"id":"48c7244d0da0ad47","repo":"AlistGo/alist","slug":"user-not-found-w","errorCode":null,"errorMessage":"user not found: %w","messagePattern":"user not found: %w","errorType":"http","errorClass":null,"httpStatus":401,"severity":"error","filePath":"server/mcp/auth.go","lineNumber":75,"sourceCode":"\t\t}\n\t\tif guest.Disabled {\n\t\t\treturn nil, fmt.Errorf(\"guest user is disabled\")\n\t\t}\n\t\tif err := loadRoles(guest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn guest, nil\n\t}\n\n\t// JWT token\n\tclaims, err := common.ParseToken(token)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid token: %w\", err)\n\t}\n\n\tuser, err := op.GetUserByName(claims.Username)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"user not found: %w\", err)\n\t}\n\n\tif claims.PwdTS != user.PwdTS {\n\t\treturn nil, fmt.Errorf(\"password has been changed\")\n\t}\n\tif user.Disabled {\n\t\treturn nil, fmt.Errorf(\"user is disabled\")\n\t}\n\n\tif err := loadRoles(user); err != nil {\n\t\treturn nil, err\n\t}\n\treturn user, nil\n}\n\nfunc loadRoles(user *model.User) error {\n\tif len(user.Role) > 0 {\n\t\troles, err := op.GetRolesByUserID(user.ID)","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/server/mcp/auth.go#L57-L93","documentation":"Returned by authenticateToken (server/mcp/auth.go:75) when the JWT parsed fine but op.GetUserByName(claims.Username) fails — the username encoded in the token no longer exists in the database. The token's signature and expiry are valid; the account behind it was deleted.","triggerScenarios":"An MCP client keeps using a login token after the referenced user account was deleted from the admin panel; a database restore that dropped user rows while tokens persisted in clients.","commonSituations":"Offboarding a user while their automation tokens remain configured; environments rebuilt from partial backups.","solutions":["Re-login as an existing user and replace the token in the MCP configuration","Remove stale credentials from tooling when accounts are deleted","Purge cached tokens on auth failures instead of retrying them"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"user not found\") { invalidateCachedToken(); promptReLogin() }","preventionTips":["Drop cached tokens when accounts are deleted","Prefer long-lived service accounts for automation"],"tags":["mcp","auth","user-management"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}