# JSON::ParserError on Jobs::VersionCheck

**URL:** https://meta.discourse.org/t/json-parsererror-on-jobs-versioncheck/64650
**Category:** Bug
**Created:** [June 17, 2017, 12:44am UTC](https://meta.discourse.org/t/json-parsererror-on-jobs-versioncheck/64650 "2017-06-17T00:44:00Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![AlbertA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alberta/32/73923_2.png) [@AlbertA](https://meta.discourse.org/u/AlbertA)
#### Post date: [June 17, 2017, 12:44am UTC](https://meta.discourse.org/t/json-parsererror-on-jobs-versioncheck/64650/1 "2017-06-17T00:44:00Z")

</div>

Hi!

I just installed a forum on an ubuntu 16.04 linode instance using docker instructions.

I also created an instance on a local VM so I could import my old smf2 based forum to it.

Once imported I created a backup in the local VM through the discourse backup tab.

I then applied this backup onto my linode instance following these instructions:

> [@Is there any way to restore your site from backup in the terminal?](https://meta.discourse.org/t/is-there-any-way-to-restore-your-site-from-backup-in-the-terminal/42377/9):
>
> It worked for me by first getting into the app ./launcher enter app then discourse enable\_restore discourse restore \<filename.of.the.backup.tar.gz\> discourse disable\_restore Using the script/discourse didn’t work

Everything seems to work fine except the version check in the admin dashboard: “A check for updates has not been performed. Ensure sidekiq is running.”

I’m using the latest release of discourse (as of this post discourse (c5f42f0) ) and HTTPS is enabled.

Sidekiq is running and actually has a few retry jobs all with:

> ` Jobs::HandledExceptionWrapper: Wrapped JSON::ParserError: 743: unexpected token at '<html> <head> <title>Discourse</title> <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,600,700...`

The logs say:

> ```
> Job exception: 743: unexpected token at '<html> <head> <title>Discourse</title> <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,600,700" rel="stylesheet" type="text/css"> <sty
> 7:15 pm
> Job exception: 743: unexpected token at '<html>
> <head>
> <title>Discourse</title>
> 
> ```

> ```
> <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,600,700" rel="stylesheet" type="text/css">
> <style>
> body {
> font-family: 'Open Sans',Arial,sans-serif;
> background-color: rgb(231,238,247);
> background-image: url('https://discourse-cdn.s3.amazonaws.com/bg.jpg');
> background-repeat: repeat;
> background-position: left top;
> padding-bottom: 3em;
> }
> 
> ```

> ```
> #logo {
> width: 80%;
> }
> 
> ```

> ```
> #discourse-twitter {
> margin-top: 2em;
> }
> 
> ```

> ```
> .content {
> width: 60%;
> max-width: 600px;
> margin: 1em auto;
> background-color: white;
> padding: 1em;
> box-shadow: 0 5px 10px rgba(0,0,0,0.2);
> border-radius: 2px;
> border: 1px solid #ccc;
> }
> 
> ```

> ```
> h1 {
> text-align: center;
> font-size: 1.5em;
> color: #666;
> font-weight: normal;
> }
> </style>
> </head>
> 
> ```

> ```
> <body>
> <div class='content'>
> 
> ```

> ```
> <center><img src="https://discourse-cdn.s3.amazonaws.com/discourse-logo.png" id='logo' alt='Discourse'></center>
> 
> ```

> ```
> <h1>Sorry, we're experiencing technical difficulties!</h1>
> 
> ```

> ```
> <center><img src="https://global.discourse-cdn.com/meta/images/emoji/twitter/frowning.png" width="72" height="72" alt="frowning"></center>
> 
> ```

> ```
> <p>This community can't be reached at the moment.
> <strong>Our team has been alerted and we're working on it.</strong></p>
> 
> ```

> ```
> <p>Please follow <a href="https://twitter.com/discourse">@discourse</a> for updates.</p>
> 
> ```

> ```
> <div id='discourse-twitter'>
> <center>
> <a class="twitter-timeline" href="https://twitter.com/discourse" data-widget-id="596039779378208769">Tweets by @discourse</a>
> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
> </center>
> </div>
> </div>
> 
> ```

> ```
> </body>
> </html>
> '
> 
> ```

backtrace:

> ```
> /usr/local/lib/ruby/2.4.0/json/common.rb:156:in `parse'
> /usr/local/lib/ruby/2.4.0/json/common.rb:156:in `parse'
> /var/www/discourse/lib/discourse_hub.rb:43:in `singular_action'
> /var/www/discourse/lib/discourse_hub.rb:27:in `get'
> /var/www/discourse/lib/discourse_hub.rb:13:in `discourse_version_check'
> /var/www/discourse/app/jobs/scheduled/version_check.rb:13:in `execute'
> /var/www/discourse/app/jobs/base.rb:154:in `block (2 levels) in perform'
> 
> ```

So it seems version check is expecting a JSON response but it’s not getting it.  
Any ideas how I could resolve this?

I’ve already rebooted the node and ./launch rebuild app with no effect.

---

<div class="post-metadata">

### Author: ![ichigons99](https://avatars.discourse-cdn.com/v4/letter/i/e274bd/32.png) [@ichigons99](https://meta.discourse.org/u/ichigons99)
#### Post date: [June 17, 2017, 2:34am UTC](https://meta.discourse.org/t/json-parsererror-on-jobs-versioncheck/64650/2 "2017-06-17T02:34:08Z")

</div>

I am facing a similar issue in one of my installations. Although, in my end it was a completely fresh install and no backup/restore procedure.

---

<div class="post-metadata">

### Author: ![AlbertA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alberta/32/73923_2.png) [@AlbertA](https://meta.discourse.org/u/AlbertA)
#### Post date: [June 17, 2017, 4:20pm UTC](https://meta.discourse.org/t/json-parsererror-on-jobs-versioncheck/64650/3 "2017-06-17T16:20:02Z")

</div>

I’ve narrowed the problem down to this commit:

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

RestClient works but Excon doesn’t on my setup.

---

<div class="post-metadata">

### Author: ![AlbertA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alberta/32/73923_2.png) [@AlbertA](https://meta.discourse.org/u/AlbertA)
#### Post date: [June 17, 2017, 4:29pm UTC](https://meta.discourse.org/t/json-parsererror-on-jobs-versioncheck/64650/4 "2017-06-17T16:29:03Z")

</div>

Net::HTTP also works fine:

> ./launcher enter app  
> rails c  
> [1] pry(main)\> uri = URI.parse(“[https://api.discourse.org/api/version\_check](https://api.discourse.org/api/version_check)”)  
> =\> #\<URI::HTTPS [https://api.discourse.org/api/version\_check](https://api.discourse.org/api/version_check)\>  
> [2] pry(main)\> Net::HTTP.get(uri)  
> =\> “{"success":"OK","latestVersion":"1.8.1"}”

Excon returns status 503:

> [3] pry(main)\> Excon.get(“[https://api.discourse.org/api/version\_check](https://api.discourse.org/api/version_check)”)

---

<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: [June 17, 2017, 4:31pm UTC](https://meta.discourse.org/t/json-parsererror-on-jobs-versioncheck/64650/5 "2017-06-17T16:31:19Z")

</div>

Any thoughts @tgxworld?

---

<div class="post-metadata">

### Author: ![AlbertA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alberta/32/73923_2.png) [@AlbertA](https://meta.discourse.org/u/AlbertA)
#### Post date: [June 17, 2017, 5:25pm UTC](https://meta.discourse.org/t/json-parsererror-on-jobs-versioncheck/64650/6 "2017-06-17T17:25:44Z")

</div>

Found the issue.

Excon adds a port number in the headers “Host” entry by default (ex. Host: [api.discourse.org:443](http://api.discourse.org:443)) and I suppose the server at [api.discourse.org](http://api.discourse.org) does not like that.

Here’s a fix:  
[https://github.com/discourse/discourse/pull/4935](https://github.com/discourse/discourse/pull/4935)

---

<div class="post-metadata">

### Author: ![Cyclops](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cyclops/32/119674_2.png) [@Cyclops](https://meta.discourse.org/u/Cyclops)
#### Post date: [June 18, 2017, 6:42am UTC](https://meta.discourse.org/t/json-parsererror-on-jobs-versioncheck/64650/7 "2017-06-18T06:42:17Z")

</div>

I applied the fix that you committed manually, since it was a simple change and now the warning goes away in Discourse’s admin panel, but if I look in sidekiq it says that VersionCheck still failed. Is there a way to confirm if it is actually working or not?

![](https://global.discourse-cdn.com/meta/optimized/3X/e/b/eb165b3300f0c49ba76c1cf7c125242f829c2031_2_690x53.png)

And in the error log I see (under Info):

```
Job exception: undefined method `>' for nil:NilClass

```

under Backtrace:

```
/var/www/discourse/app/jobs/scheduled/version_check.rb:23:in `execute'

```

/var/www/discourse/app/jobs/base.rb:154:in `block (2 levels) in perform’

under Env:

```
hostname	hal-app
process_id	104
application_version	c5f42f0e97b27bacd24d07c3180f9b485880e2fc
current_db	default
current_hostname	forum.blazingumbra.com
job	Jobs::VersionCheck
problem_db	default
opts	

```

Clearly something is wrong.

---

<div class="post-metadata">

### Author: ![AlbertA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alberta/32/73923_2.png) [@AlbertA](https://meta.discourse.org/u/AlbertA)
#### Post date: [June 18, 2017, 9:54am UTC](https://meta.discourse.org/t/json-parsererror-on-jobs-versioncheck/64650/8 "2017-06-18T09:54:14Z")

</div>

Yeah it looks like a separate issue. The query itself is incorrect as it tries to set a body in a GET request instead of query parameters.  
Without the query parameters, the json response only has two fields and was missing ‘missingVersionsCount’ (hence nil \> 0 which causes an exception).

I’ve updated the PR.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [June 18, 2017, 10:52pm UTC](https://meta.discourse.org/t/json-parsererror-on-jobs-versioncheck/64650/9 "2017-06-18T22:52:42Z")

</div>

Thank you for fixing @AlbertA 👍

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [June 20, 2017, 9:00am UTC](https://meta.discourse.org/t/json-parsererror-on-jobs-versioncheck/64650/12 "2017-06-20T09:00:17Z")

</div>

This topic was automatically closed after 34 hours. New replies are no longer allowed.
