Charcoal-SE / metasmoke

Web dashboard for SmokeDetector.
https://metasmoke.erwaysoftware.com
Creative Commons Zero v1.0 Universal
43 stars 34 forks source link

MS fails to autoflag with "Devise could not find the Warden::Proxy instance..." #510

Closed makyen closed 6 years ago

makyen commented 6 years ago

This MS post only received 1 autoflag where I'd expect it to receive 3 or 4 autoflags. The flag logs indicate that an additional flag was attempted, but encountered a real error (appears to be a Rails error on MS; i.e. not just a normal SE API response), which may have resulted in no more autoflags being placed.

The error text displayed as a toolip begins with:

Devise could not find the Warden::Proxy instance on your request environment
ArtOfCode- commented 6 years ago

This happens because of this line:

https://github.com/Charcoal-SE/metasmoke/blob/a82b18bdb8fc0b2be4aec770877361af4520cf5f/app/models/concerns/post_concerns/autoflagging.rb#L144

We're rendering a view manually from the controller. When you do that, Rails doesn't include the middleware stack while rendering (see this SO answer), so Devise can't find a Warden instance because there isn't one.

Since these renders are just for realtime updates and the only thing we need Devise/Warden for there is an admin feature... I'm just gonna drop the link that's causing this for the realtime updates.