grnhse / greenhouse_io

Ruby API wrapper for Greenhouse.io API
MIT License
44 stars 46 forks source link

link header contains duplicate query params #21

Closed jeffweiss closed 8 years ago

jeffweiss commented 8 years ago

The Ruby client illustrates this problem, but the issue lies with the underlying Harvest API service.

Problem

When passing parameters for page and per_page, the link header for the results contain both the current page parameters and the next page parameters.

Example

https://harvest.greenhouse.io/v1/applications?page=2&page=3&per_page=1&per_page=1

Steps to Reproduce (Ruby)

$ irb -rgreenhouse_io
>> gh_client = GreenhouseIo::Client.new(redacted)
=> #<GreenhouseIo::Client:0x007ff5eb85e4e8 @api_token=redacted>
>> gh_client.link
=> nil
>> gh_client.applications(nil, per_page: 1)
=> [...redacted...]
>> gh_client.link
=> "<https://harvest.greenhouse.io/v1/applications?page=2&per_page=1&per_page=1>; rel=\"next\",<https://harvest.greenhouse.io/v1/applications?page=24882&per_page=1&per_page=1>; rel=\"last\""
>> gh_client.applications(nil, page: 2, per_page: 1)
=> [...redacted...]
>> gh_client.link
=> "<https://harvest.greenhouse.io/v1/applications?page=2&page=3&per_page=1&per_page=1>; rel=\"next\",<https://harvest.greenhouse.io/v1/applications?page=1&page=2&per_page=1&per_page=1>; rel=\"prev\",<https://harvest.greenhouse.io/v1/applications?page=2&page=24882&per_page=1&per_page=1>; rel=\"last\""

Steps to Reproduce (curl)

$ curl -v https://harvest.greenhouse.io/v1/applications\?per_page\=1 -u redacted
*   Trying 54.225.221.123...
* Connected to harvest.greenhouse.io (54.225.221.123) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.greenhouse.io
* Server certificate: RapidSSL SHA256 CA - G3
* Server certificate: GeoTrust Global CA
> GET /v1/applications?per_page=1 HTTP/1.1
> Host: harvest.greenhouse.io
> Authorization: Basic redacted
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Cowboy
< Connection: keep-alive
< Date: Wed, 11 May 2016 05:58:25 GMT
< Status: 200 OK
< Content-Type: application/json;charset=utf-8
< Link: <https://harvest.greenhouse.io/v1/applications?page=2&per_page=1&per_page=1>; rel="next",<https://harvest.greenhouse.io/v1/applications?page=24882&per_page=1&per_page=1>; rel="last"

$ curl -v https://harvest.greenhouse.io/v1/applications\?page\=2\&per_page\=1 -u redacted
*   Trying 23.21.54.152...
* Connected to harvest.greenhouse.io (23.21.54.152) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.greenhouse.io
* Server certificate: RapidSSL SHA256 CA - G3
* Server certificate: GeoTrust Global CA
> GET /v1/applications?page=2&per_page=1 HTTP/1.1
> Host: harvest.greenhouse.io
> Authorization: Basic redacted
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Cowboy
< Connection: keep-alive
< Date: Wed, 11 May 2016 05:59:50 GMT
< Status: 200 OK
< Content-Type: application/json;charset=utf-8
< Link: <https://harvest.greenhouse.io/v1/applications?page=2&page=3&per_page=1&per_page=1>; rel="next",<https://harvest.greenhouse.io/v1/applications?page=1&page=2&per_page=1&per_page=1>; rel="prev",<https://harvest.greenhouse.io/v1/applications?page=2&page=24882&per_page=1&per_page=1>; rel="last"
capablemonkey commented 8 years ago

Thanks for creating this issue @jeffweiss and sorry for the delay.

I can confirm this is an issue with the Harvest API. So far, it looks like only the /v1/applications endpoint is affected by this bug. I'll follow up with more details as we investigate.

capablemonkey commented 8 years ago

Hey @jeffweiss, just want to let you know that we deployed a fix for this yesterday. This bug appears to be fixed now. Would you mind quickly confirming on your end?

Thanks again for letting us know about this bug, and sorry for the inconvenience!