Skip to content

Bug with OPTIONS method and Grape 0.18.0 ? #1519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
thiagohdeplima opened this issue Nov 11, 2016 · 1 comment
Closed

Bug with OPTIONS method and Grape 0.18.0 ? #1519

thiagohdeplima opened this issue Nov 11, 2016 · 1 comment

Comments

@thiagohdeplima
Copy link

I start a new project today.

This project have the following routes:

get do
  passengers = Passenger.order(:name)

  query = declared(params, include_missing: false)

  unless query.count.zero? then
    passengers = passengers.where(query)
  end

  present passengers.offset(@start).limit(@count).all,
    with: API::V1::Entities::Passenger
end

params do
  requires :name, type: String
  requires :email, type: String
  requires :mobile, type: String
  requires :password, type: String
end
post do
  present Passenger.create(declared(params)),
    with: API::V1::Entities::Passenger
end

Occurs which in grape 0.18.0, when the app receive an request with OPTIONS method, the response is the following:

$ curl -X OPTIONS localhost:9292/v1/passengers -v
*   Trying ::1...
* connect to ::1 port 9292 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 9292 (#0)
> OPTIONS /v1/passengers HTTP/1.1
> Host: localhost:9292
> User-Agent: curl/7.49.1
> Accept: */*
>
< HTTP/1.1 400 Bad Request
< Content-Type: application/json
< Content-Length: 85
<
* Connection #0 to host localhost left intact
{"error":"name is missing, email is missing, mobile is missing, password is missing"}

In other project, I use version 0.14.0. Downgrading this project from 0.18.0 to same version, without any other change, the OPTIONS method start working, as bellow:

$ curl -X OPTIONS localhost:9292/v1/passengers -v
*   Trying ::1...
* connect to ::1 port 9292 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 9292 (#0)
> OPTIONS /v1/passengers HTTP/1.1
> Host: localhost:9292
> User-Agent: curl/7.49.1
> Accept: */*
>
< HTTP/1.1 204 No Content
< Allow: OPTIONS, GET, POST, HEAD
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: Accept
<
* Connection #0 to host localhost left intact

I test with others grape versions (0.15.0 and 0.17.0), and I could not reproduce this bug, it occours only in 0.18.0

@dblock
Copy link
Member

dblock commented Nov 12, 2016

I am pretty sure this is a duplicate of #1505, already fixed on HEAD, give it a try to confirm?

@dblock dblock closed this as completed Nov 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants