biola / turnout

Turnout makes it easy to put Rack apps into maintenance mode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Calls to application API generate error when in maintenance

treydock opened this issue · comments

I have an application that has an API backend that uses versioning and have noticed when I put the application into maintenance using turnout the API calls generate exceptions.

This is the exception generated:

A RuntimeError occurred in #:

  Invalid header value: "application/emop; version=1"
  config/initializers/quiet_assets.rb:6:in `call_with_quiet_assets'

The code using the API is setting the "Accept" HTTP header to be "application/emop; version=1".

The Rails application is here - https://github.com/Early-Modern-OCR/emop-dashboard

Let me know if this is specific to turnout or if this could be caused by another issue. The issue only happens when maintenance is enabled.

Thanks,

  • Trey

It looks like this is actually a problem with rack-accept which is a dependency of turnout. I'd suggest opening an issue over there.

Looks like this is where the error is being raised.

You'll notice that if you run your accept header against the regex it's using, it doesn't match. However, removing the space seems to fix it if you're looking for an easy workaround.

/^([^\s,]+?)(?:\s*;\s*q\s*=\s*(\d+(?:\.\d+)?))?$/.match('application/emop; version=1') #=> nil
/^([^\s,]+?)(?:\s*;\s*q\s*=\s*(\d+(?:\.\d+)?))?$/.match('application/emop;version=1') #=> #<MatchData "application/emop;version=1" 1:"application/emop;version=1" 2:nil>