Unable to delete agent, thrown to ActiveRecord::RecordNotFound screen. #399

Closed
virtadpt opened this Issue Jul 10, 2014 · 16 comments

Comments

Projects
None yet
3 participants
Contributor

virtadpt commented Jul 10, 2014

I'm reworking part of my agent network and I'm trying to delete an agent because I can't change what type it is. When I try to do so with the Delete (or Disable, for that matter) function, I'm thrown to an "ActiveRecord::RecordNotFound" screen. Details from this screen:

Couldn't find Agent with 'id'=39 [WHERE agents.user_id = ?]

In the app/controllers/agents_controller.rb subwindow (starting at row 120):

      end
    end
  end
  def update
    @agent = current_user.agents.find(params[:id])
    respond_to do |format|
      if @agent.update_attributes(params[:agent])
        format.html { redirect_back "'#{@agent.name}' was successfully updated." }
        format.json { render json: @agent, status: :ok, location: agent_path(@agent) }

Line 125 (@agent = current_user.agents.find(params[:id])) is highlighted.

I can get more information if you need it, just tell me what would be helpful.

Owner

cantino commented Jul 11, 2014

Could you try running bundle exec rails console and typing Agent.find(39) and seeing if it can be found. It seems like it's trying to access an agent that doesn't exist, or it's somehow owned by a different user.

Contributor

virtadpt commented Jul 12, 2014

drwho@exocortex:~/huginn(3)$ bundle exec rails console
Loading development environment (Rails 4.1.1)
irb(main):001:0> Agent.find(39)
  Agent Load (0.3ms)  SELECT  `agents`.* FROM `agents`  WHERE `agents`.`id` = 39 LIMIT 1
ActiveRecord::RecordNotFound: Couldn't find Agent with 'id'=39
        from /var/lib/gems/1.9.1/gems/activerecord-4.1.1/lib/active_record/relation/finder_methods.rb:320:in `raise_record_not_found_exception!'
        from /var/lib/gems/1.9.1/gems/activerecord-4.1.1/lib/active_record/relation/finder_methods.rb:420:in `find_one'
        from /var/lib/gems/1.9.1/gems/activerecord-4.1.1/lib/active_record/relation/finder_methods.rb:404:in `find_with_ids'
        from /var/lib/gems/1.9.1/gems/activerecord-4.1.1/lib/active_record/relation/finder_methods.rb:68:in `find'
        from /var/lib/gems/1.9.1/gems/activerecord-4.1.1/lib/active_record/querying.rb:3:in `find'
        from (irb):1
        from /var/lib/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands/console.rb:90:in `start' 
        from /var/lib/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands/console.rb:9:in `start'  
        from /var/lib/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands/commands
_tasks.rb:69:in `console'
        from /var/lib/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
        from /var/lib/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

There's only one user on this Huginn instance so I'm not sure it has anything to do with that particular agent being owned by someone else.

Owner

cantino commented Jul 12, 2014

Interesting. So there really is no Agent with ID 39, but when you go to your Agent list, it shows one with that id? I ask because the SQL error you showed me

Couldn't find Agent with 'id'=39 [WHERE agents.user_id = ?]

is trying to find an Agent with id 39. If you look at the URLs to your agents in the list, each one shows an id at the end. It sounds like at the time you did this, you followed a link to an agent that no longer existed. Could you have removed it in a different browser tab?

Member

alias1 commented Jul 13, 2014

Going back to basics, but you've tried reloading the page, clearing the browser cache, your not linking directly to an agent from as bookmark, etc yeah?—
Sent from Mailbox

On Sun, Jul 13, 2014 at 7:42 AM, Andrew Cantino notifications@github.com
wrote:

Interesting. So there really is no Agent with ID 39, but when you go to your Agent list, it shows one with that id? I ask because the SQL error you showed me
Couldn't find Agent with 'id'=39 [WHERE agents.user_id = ?]

is trying to find an Agent with id 39. If you look at the URLs to your agents in the list, each one shows an id at the end.

Reply to this email directly or view it on GitHub:
cantino#399 (comment)

alias1 added the bug label Jul 14, 2014

Contributor

virtadpt commented Jul 17, 2014

@alais1: I did those things first. I'm not using a bookmark to go right to the agent, either. I usually try to visit agents' pages from either scenarios or from links to them on the pages of dependent agents.

I've been able to recreate the bug this afternoon when deleting a newly created agent. I had clicked on an agent that depends upon it, and then clicked on the name of the agent I'm trying to delete as a shortcut to get to it, and got the Couldn't find Agent with 'id'=69 [WHEREagents.user_id= ?] error again.

The problem seems to arise from the "Your Agents" page not being updated after an agent is deleted. The link is still there even though the agent's already been deallocated.

It seems as if a "This agent has already been deleted" page would be a nicer user experience than an ActiveRecord::RecordNotFound error console.

Owner

cantino commented Jul 18, 2014

This is very odd @virtadpt. I've never seen the behvaior where the page caches and shows a deleted Agent. So you're in the /agents list, you click on the menu next to an agent, select Delete agent, confirm at the prompt, and the page doesn't reload showing the Agent having been removed?

If this is the case, would you mind opening the JavaScript console in your web browser and seeing if an error is displayed when you click on Delete agent and confirm?

Contributor

virtadpt commented Jul 18, 2014

No. Let's say I have two agents, Alpha and Beta, and Beta depends on events from Alpha. They're both in a scenario called Scenario.

I click on the scenario and then click on Beta. Actions -> Delete -> Confirm.

ActiveRecord::RecordNotFound at /agents/71

If I go back to /agents, the agent is indeed gone.

Let me recreate this again with Firebug's JS console open...

reflow: 0.29ms
POST https://exocortex.virtadpt.net/agents/73 [HTTP/1.1 302 Found  44ms]
GET https://exocortex.virtadpt.net/agents/73 [HTTP/1.1 404 Not Found  45ms]
reflow: 0ms
reflow: 0.09ms
reflow: 0.25ms
Unknown property 'box-sizing'.  Declaration dropped. 73:95
Error in parsing value for 'background'.  Declaration dropped. 73:258
Expected color but found 'top'.  Error in parsing value for 'background'.  Declaration dropped. 73:260
Error in parsing value for 'word-wrap'.  Declaration dropped. 73:274
Error in parsing value for 'overflow-x'.  Declaration dropped. 73:529
Unknown pseudo-class or pseudo-element '-webkit-scrollbar'.  Ruleset ignored due to bad selector. 73:655
Unknown pseudo-class or pseudo-element '-webkit-scrollbar-thumb'.  Ruleset ignored due to bad selector. 73:663
Unknown pseudo-class or pseudo-element '-webkit-scrollbar-thumb'.  Ruleset ignored due to bad selector. 73:670
Unknown pseudo-class or pseudo-element '-webkit-scrollbar-thumb'.  Ruleset ignored due to bad selector. 73:675
Unknown pseudo-class or pseudo-element '-webkit-scrollbar-thumb'.  Ruleset ignored due to bad selector. 73:680
POST https://exocortex.virtadpt.net/__better_errors/70101692707120/variables [HTTP/1.1 200 OK  26ms]
reflow: 0.93ms function switchTo, 73 line 1968
reflow: 1.13ms function switchTo, 73 line 1968
reflow: 0.03ms

The GET fails: GET https://exocortex.virtadpt.net/agents/73 [HTTP/1.1 404 Not Found 45ms]

This is weird.

Owner

cantino commented Jul 18, 2014

Thanks for the details. I'll see if I can reproduce it tonight.

Owner

cantino commented Jul 19, 2014

Okay, I tried deleting agents from Scenarios, both as the source and receiver of events, and cannot reproduce this. Would you mind making a screencast showing the issue? Really sorry about this!

Contributor

virtadpt commented Jul 21, 2014

I'll give it a try. I got frustrated trying to record a screencast of it too late at night and, after fighting with that URF-8 database issue just updated to a newer checkout. I still have the system state archived, though.

Owner

cantino commented Jul 23, 2014

Sorry that it's been frustrating. You're encountering an issue I've never seen before, but I would like to get it fixed.

Contributor

virtadpt commented Nov 10, 2014

Ticket #531 involved this particular bug. When #531 was fixed, this was fixed - I can't reproduce the bug anymore.

virtadpt closed this Nov 10, 2014

virtadpt reopened this Nov 25, 2014

Contributor

virtadpt commented Nov 25, 2014

I'm able to reliably recreate this issue. I should have time tomorrow to do it before Thanksgiving madness sets in.

Owner

cantino commented Nov 26, 2014

Darn, okay. Thanks!

Contributor

virtadpt commented Mar 6, 2015

As of commit 26a8e49, I no longer see this happen. Things are now working as expected when deleting agents. \0/

Owner

cantino commented Mar 6, 2015

Yay!

cantino closed this Mar 6, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment