# Errors when user posts

**URL:** https://meta.discourse.org/t/errors-when-user-posts/27858
**Category:** Support
**Created:** [April 23, 2015, 1:18pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858 "2015-04-23T13:18:14Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![CCSAwebdev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ccsawebdev/32/41077_2.png) [@CCSAwebdev](https://meta.discourse.org/u/CCSAwebdev)
#### Post date: [April 23, 2015, 1:18pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858/1 "2015-04-23T13:18:14Z")

</div>

Getting a lot of errors when users attempt to post. Any idea what could could be causing this?

```
Job exception: Wrapped ActiveRecord::RecordNotFound: Couldn't find Post with 'id'=86 [WHERE ("posts"."deleted_at" IS NULL)]

```

10 hrs ago  
!

```
Job exception: Couldn't find Post with 'id'=98 [WHERE ("posts"."deleted_at" IS NULL)]

```

9 hrs ago  
!

```
Job exception: Wrapped ActiveRecord::RecordNotFound: Couldn't find Post with 'id'=98 [WHERE ("posts"."deleted_at" IS NULL)]

```

9 hrs ago  
!

```
Job exception: Couldn't find Post with 'id'=86 [WHERE ("posts"."deleted_at" IS NULL)]

```

6 hrs ago  
!

```
Job exception: Wrapped ActiveRecord::RecordNotFound: Couldn't find Post with 'id'=86 [WHERE ("posts"."deleted_at" IS NULL)]

```

6 hrs ago  
!

```
Job exception: Couldn't find Post with 'id'=98 [WHERE ("posts"."deleted_at" IS NULL)]

```

5 hrs ago  
!

```
Job exception: Wrapped ActiveRecord::RecordNotFound: Couldn't find Post with 'id'=98 [WHERE ("posts"."deleted_at" IS NULL)]

```

5 hrs ago

---

<div class="post-metadata">

### Author: ![kcoop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kcoop/32/108612_2.png) [@kcoop](https://meta.discourse.org/u/kcoop)
#### Post date: [October 27, 2015, 5:41pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858/2 "2015-10-27T17:41:26Z")

</div>

I’m seeing this too, quite a bit.

I think this bug is in post\_alert.rb (I don’t have a fork of Discourse installed, sorry, so no pull request):

```
def execute(args)
  # maybe it was removed by the time we are making the post
  if post = Post.find(args[:post_id])
    # maybe the topic was deleted, so skip in that case as well
    PostAlerter.post_created(post) if post.topic
  end
end

```

It looks like the find should be a find\_by\_id.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 27, 2015, 6:43pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858/3 "2015-10-27T18:43:30Z")

</div>

Maybe @eviltrout can you have a look?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [October 27, 2015, 8:04pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858/4 "2015-10-27T20:04:08Z")

</div>

You are seeing this when users post? Because that error is from a background job and the code path should not be triggered until after the post goes through.

Can you provide more of the logs from when these errors occur? We are not seeing the same thing in our logs and I’d like to find out exactly where it’s happening.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 27, 2015, 8:09pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858/5 "2015-10-27T20:09:58Z")

</div>

yeah curious, what is the end user impact here? if the bg job fails its just log noise (log noise that we should fix)

---

<div class="post-metadata">

### Author: ![kcoop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kcoop/32/108612_2.png) [@kcoop](https://meta.discourse.org/u/kcoop)
#### Post date: [October 27, 2015, 8:34pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858/6 "2015-10-27T20:34:34Z")

</div>

No end user impact AFAICT. Just log noise. But as a noob it’s comforting not to see error messages in my log.

BTW, what’s the best way to report other error messages I’m seeing? Just post them as bug topics? Do you care?

Also, major kudos for the log system. Love it that JS errors appear there as well.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 27, 2015, 11:07pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858/7 "2015-10-27T23:07:50Z")

</div>

We need the complete stack trace, can you please post it here?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 27, 2015, 11:25pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858/8 "2015-10-27T23:25:35Z")

</div>

Feel free to report errors as you go, in existing topics or new ones. Or even submit PRs if you can.

This one does look like an oversight, easily fixable. Indicates that the post was deleted by the time the job queue caught up to creating alerts

---

<div class="post-metadata">

### Author: ![kcoop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kcoop/32/108612_2.png) [@kcoop](https://meta.discourse.org/u/kcoop)
#### Post date: [October 27, 2015, 11:33pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858/9 "2015-10-27T23:33:21Z")

</div>

Ok, but I think this one’s pretty obvious.

```
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/relation/finder_methods.rb:324:in `raise_record_not_found_exception!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/relation/finder_methods.rb:444:in `find_one'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/relation/finder_methods.rb:423:in `find_with_ids'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/relation/finder_methods.rb:71:in `find'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/querying.rb:3:in `find'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.4/lib/active_record/core.rb:131:in `find'
/var/www/discourse/app/jobs/regular/post_alert.rb:6:in `execute'
/var/www/discourse/app/jobs/base.rb:154:in `block (2 levels) in perform'

```

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 27, 2015, 11:35pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858/10 "2015-10-27T23:35:44Z")

</div>

> [@sam](#):
>
> Indicates that the post was deleted by the time the job queue caught up to creating alerts

If that’s the case we should ignore this set of conditions @eviltrout.

---

<div class="post-metadata">

### Author: ![kcoop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kcoop/32/108612_2.png) [@kcoop](https://meta.discourse.org/u/kcoop)
#### Post date: [October 27, 2015, 11:38pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858/11 "2015-10-27T23:38:25Z")

</div>

> [@sam](#):
>
> Or even submit PRs if you can.

Whenever I create a forked repo, it gets tempting to make my own changes… 🍩

But I do see the value.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [October 28, 2015, 5:04pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858/12 "2015-10-28T17:04:46Z")

</div>

Thanks. It looks like the code tried to do this but used `find` which does not return `nil` for missing posts.

Fixed here:

[https://github.com/discourse/discourse/commit/971af6a762d64afc24cc6a0c451322672a9d68fc](https://github.com/discourse/discourse/commit/971af6a762d64afc24cc6a0c451322672a9d68fc)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 28, 2015, 8:28pm UTC](https://meta.discourse.org/t/errors-when-user-posts/27858/13 "2015-10-28T20:28:10Z")

</div>


