Customization hangs on save


(Ted Strauss) #1

I am trying to update site customizations (header, css, etc) and when I hit the save button it just hangs, like so:

Context:

  • I recently locked myself of the site and had to disable all customizations with this command: SiteCustomization.update_all(enabled: false)
  • (i also disable sso settings to fix the lockout, but seems unrelated)
  • then restarted docker: sudo service docker restart
  • the bug appeared after that

Which logs should I be looking at for this: Postgres, nginx?


(Mittineague) #2

Have you tried
SiteCustomization.update_all(enabled: true)
since then?


(Ted Strauss) #3

No, wouldn’t that try to enable all of the customizations when only one should be enabled at a time.
Doesn’t seem like the right thing. Is it just a guess or do you have reason for suggesting this?


(Mittineague) #4

Yes, only a guess. my thinking is that the update_all is “stuck” at false

I don’t know, but I don’t think enabled means all customizations will be enabled, only that their state of being enabled or not can be updated.
i.e. it is the update-ability that is enabled, not the customizations.

If you fear things becoming more broken, please wait for a more authoritative reply.
Not everyone should take “best guess” chances like I would.


(Ted Strauss) #5

I tried that command and there’s no change in the behavior. Bug still there.


(Kane York) #6

When you hit save, is there anything in the browser developer console? Is there anything at /logs ?


(Ted Strauss) #7

Here’s what the chrome dev console outputs:

> Error: Forbidden
>     at o (_vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:37324)
>     at Object.e.default.trigger (_vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:56277)
>     at h._onerror (_vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:57291)
>     at p (_vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:55522)
>     at _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:37309
>     at r.invoke (_vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:11597)
>     at Object.r.flush (_vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:11662)
>     at Object.n.flush (_vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:11467)
>     at Object.s.end (_vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:10892)
>     at Object.s.run (_vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:10947)
o @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:37347
e.default.trigger @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:56277
h._onerror @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:57291
p @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:55522
(anonymous function) @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:37309
r.invoke @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:11597
r.flush @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:11662
n.flush @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:11467
s.end @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:10892
s.run @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:10947
l @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:26183
Discourse.Ajax.Em.Mixin.create.ajax.a.error @ _application-5b9ede902f5f6907350c108cccfc6434.js:84
J.Callbacks.c @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:3364
J.Callbacks.h.fireWith @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:3364
r @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:3366
J.ajaxTransport.Y.cors.e.crossDomain.send.t @ _vendor-8ac38deb4cd1032c9e36e9a558d4cd97.js:3366

The logs and error logs don’t look pertinent.


(Kane York) #8

Okay, so that’s a network request failing. What’s the Network tab say when you click on save?


(Ted Strauss) #9

It says: 403 Forbidden and ['BAD CSRF'] in the response.

I’m pretty sure the problem is that I included JS and CSS script imports in the Top portion of the customization, and I messed up jQuery or something.


(Kane York) #10

Okay, put ?preview-style=default on the end of the URL, and you should be able to remove those.

And yes, it probably did mess up jQuery.

  1. You don’t need to add it, it’s already there.
  2. You almost always want to hook into the Ember Views instead so you can apply your changes every time the element renders.

(Ted Strauss) #11

So I added that to the end of my URL

http://mysite/admin/customize/css_html?preview-style=default

and reloaded the customization page.
Still getting the same bug.
Did I do it right?

is there a way to zap those customizations in postgres directly?


(Kane York) #12

Okay, something’s pretty screwed up then… Try rebuilding the container


Error 403 when trying to add articles or change any options
(Ted Strauss) #13

Ok it looks like I fixed it by clearing the customizations out of postgres then restarted docker.

sudo ./launcher enter app
sudo -u postgres psql discourse
discourse=# update site_customizations SET stylesheet = '';
discourse=# update site_customizations SET top = '';
discourse=# update site_customizations SET header = '';
discourse=# update site_customizations SET head_tag = '';
discourse=# \q 
exit
sudo service docker restart

fingers crossed. thanks for your help @riking