JSON::ParserError on Jobs::VersionCheck

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:

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://d11a6trkgmumsb.cloudfront.net/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.

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.

I’ve narrowed the problem down to this commit:

https://github.com/discourse/discourse/commit/d82dbd565bad213f9df026a9b3ed2300bd81fdd9

RestClient works but Excon doesn’t on my setup.

1 Like

Net::HTTP also works fine:

./launcher enter app
rails c
[1] pry(main)> uri = URI.parse(“https://api.discourse.org/api/version_check”)
=> #<URI::HTTPS 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”)

Any thoughts @tgxworld?

Found the issue.

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

Here’s a fix:
https://github.com/discourse/discourse/pull/4935

3 Likes

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?

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.

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.

3 Likes

Thank you for fixing @AlbertA :thumbsup:

2 Likes

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