Comments (13)
@dblock I just did, the test provided by @ericproulx starts failing at 3ae7b7a720911a11a933b1788fc82764fbeaf52c
, after this pr got merged
from grape.
A test like this one would have catch it
context 'cascade within another app' do
subject { last_response.headers }
let(:api) do
Class.new(Grape::API) do
get('/test'){ return_no_content }
end
end
let(:app) do
test_api = api
Rack::Builder.app do
use Rack::Lint
run test_api.new
end
end
before { get '/' }
it { is_expected.to include('x-cascade') }
end
Rack::Lint
would have raised
Rack::Lint::LintError:
uppercase character in header name: X-Cascade
from grape.
I do confirm, this test in our stack is passing in 2.0.0 but not in 2.1.0. There's is something with the /
it works when mounting to /api
.
context 'rails mounted' do
let(:app) do
require 'rails'
require 'action_controller/railtie'
api = Class.new(Grape::API) do
get('/test_grape'){ 'rails mounted' }
end
Class.new(Rails::Application) do
config.eager_load = true
config.load_defaults 7.1
config.api_only = true
config.consider_all_requests_local = true
config.hosts << 'example.org'
routes.append do
mount api => "/"
get 'up', to: ->(_env) do
['200', {}, ['hello world']]
end
end
end
end
before { app.initialize! }
it 'responds' do
get '/test_grape'
expect(last_response).to be_successful
expect(last_response.body).to eq('rails mounted')
get '/up'
expect(last_response).to be_successful
expect(last_response.body).to eq('hello world')
end
end
from grape.
@ericproulx yes, it's 3.1.3
in both my demo repo and grape's Gemfile.lock
on my machine where i did bisect
from grape.
Looks like a regression. Try porting this into a spec in this repo without rails? Then it's easy to bisect down to where it changed.
from grape.
Same problem confirmed. I'm moving the mount
definition for my Grape routes to the bottom of the routes.rb
file as a temporary fix
from grape.
Can someone bisect this to a change please?
from grape.
I found something related to the X-Cascade. I'm still digging
from grape.
@eiskrenkov are you using rack >= 3 ? While testing, I found that its only happening with Rack >= 3 but maybe I'm wrong
from grape.
Thank you so much for your work guys @dblock @ericproulx <3 Will try the new version once it's out
from grape.
@eiskrenkov please do try HEAD, github: 'ruby-grape/grape'
in Gemfile, appreciate if you could confirm the fix works.
from grape.
@dblock sure thing! Just tried it in my project, it helped! Routes that are defined under grape mounting are reachable now. Thank you so much for such a quick fix again!
from grape.
@dblock Until now, I couldn't wrap my head around this bug because obviously we had a test for cascading. While looking at the caller
when calling the default response, I figured that rack-test
processes the request with a Rack::MockResponse
which will lowercase
the headers through Rack::Response
by design. So, even though we were returning X-Cascade
, the last_response.headers
would have x-cascade
.
Now, when running within a rails app, the default-response
is managed by Rails's routing which will look for x-cascade
with Rack 3 instead of X-Cascade
.
from grape.
Related Issues (20)
- Release new version ? HOT 3
- 'context' undefined in rescue_from in 2.1.0 HOT 9
- Minor release ? HOT 1
- Grape::Util::Accept::Header : empty range in char class: /^([a-z*]+)\/([a-z0-9*&\^\- HOT 2
- Error messages depends on previous requests HOT 2
- Broken Params Type Check in Grape v2.1.x HOT 1
- Coverage is only covering specs
- original_exception and backtrace are not present even if passed in error! HOT 1
- Error when rescue Grape::Exceptions::ValidationErrors in json format with backtrance and original_exception HOT 4
- Error when validating array items with different conditionally required properties HOT 6
- Wrong quality ranking when q parameter is not a float
- Returning an invalid response in a `rescue_from` block causes “NoMethodError: undefined method 'default_rescue_handler'” HOT 5
- Danger missing write access HOT 1
- NoMethodError for nil:NilClass on headers.reverse_merge after upgrading Grape from 1.6.2 to 1.8.0 HOT 6
- How to handle exception raised in `rescue_from` block? HOT 4
- Formatting with multi_json ? HOT 4
- Include Rack::TempFileReaper in Grape ?
- Parsing query params may lead to unhandled Rack exception.
- Enforce MFA when releasing ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grape.