Skip to content
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

Incorrectly builds urls for Github Enterprise API endpoints #831

Closed
toddmohney opened this issue Nov 10, 2016 · 5 comments
Closed

Incorrectly builds urls for Github Enterprise API endpoints #831

toddmohney opened this issue Nov 10, 2016 · 5 comments

Comments

@toddmohney
Copy link

The default Github Enterprise installation exposes its API at endpoints
prefixed with /api/v3. The current version of Octokit, however, has a bug
where when configuring the api_endpoint, as recommended, results in requests to an
incorrect url.

Expected behavior

Configuring the Octokit client's api_endpoint value as

client = Octokit::Client.new(
  api_endpoint: "https://somedomain.com/api/v3",
  client_id: "123"
)

then calling client.check_application_authorization("some-token")

should result in a request to

https://somedomain.com/api/v3/applications/abc/tokens/some-token

Actual behavior

A request is made to

https://somedomain.com/applications/abc/tokens/some-token

Notice the omitted /api/v3

Steps to reproduce

We've put together a repository with a simple demonstration of this bug. Run rspec spec/test.rb from the root of this repository

Investigation

The problem can be traced down to where the request url is built in Faraday

On these lines, base is a URI instance and the + operator is defined on URI as an alias to merge which does not exhibit the same behavior as concatenation and is why the /api/v3 portion of the path gets lost.

Proposed resolution

At the moment, I'm not certain how to correct this issue from Octokit's point of view, but am happy to help.

@jrockks
Copy link

jrockks commented Dec 26, 2016

Liucevse

@gdiggs
Copy link

gdiggs commented Jan 4, 2017

@tarebyte any thoughts here?

@tarebyte
Copy link
Member

tarebyte commented Jan 5, 2017

@toddmohney @gordondiggs let me take a look to see if I can help you resolve this issue, apologies for the delay.

@tarebyte
Copy link
Member

tarebyte commented Jan 5, 2017

@toddmohney @gordondiggs after playing around with this for a bit, I think the patch is going to have to be upstream to Faraday.

Without some serious hackery I don't see how we can fix this on the Octokit side of things.

@gdiggs
Copy link

gdiggs commented Jan 5, 2017

Thanks @pengwynn @tarebyte!

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

4 participants