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

Every request results in an exception #214

Open
kassi opened this issue May 18, 2024 · 3 comments
Open

Every request results in an exception #214

kassi opened this issue May 18, 2024 · 3 comments

Comments

@kassi
Copy link

kassi commented May 18, 2024

Describe the bug
Followed the README.md

AppStoreConnect.config = {
          issuer_id: ENV["XCC_ISSUER_ID"],
          key_id: ENV["XCC_PRIVATE_KEY_ID"],
          private_key: ENV["XCC_PRIVATE_KEY"]
        }
client = AppStoreConnect::Client.new
pp client.apps

and of course filled in env variables. The call (and every other method I call on client) results in

/Users/Kassi/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/net/http/generic_request.rb:17:in `initialize': not an HTTP URI (ArgumentError)

      raise ArgumentError, "not an HTTP URI" unless URI::HTTP === uri_or_path
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	from /Users/Kassi/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/net/http/request.rb:38:in `initialize'
	from /Users/Kassi/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/app_store_connect-0.38.0/lib/app_store_connect/request.rb:89:in `new'
	from /Users/Kassi/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/app_store_connect-0.38.0/lib/app_store_connect/request.rb:89:in `request'
	from /Users/Kassi/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/app_store_connect-0.38.0/lib/app_store_connect/request.rb:20:in `block in execute'
	from /Users/Kassi/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/net/http.rb:1238:in `start'
	from /Users/Kassi/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/net/http.rb:687:in `start'
	from /Users/Kassi/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/app_store_connect-0.38.0/lib/app_store_connect/request.rb:19:in `execute'
	from /Users/Kassi/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/app_store_connect-0.38.0/lib/app_store_connect/base.rb:40:in `call'
	from /Users/Kassi/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/app_store_connect-0.38.0/lib/app_store_connect/base.rb:20:in `method_missing'

Expected behavior
Code should list all apps and not break.

Desktop (please complete the following information):

  • OS: macOS 14.4.1
  • Ruby: 3.2.2
  • Gem version: 0.38.0

Additional context
I tried to debug until generic_request.rb and the uri that is passed is an instance of URI::Generic.
I added the following into generic_request.rb at line 17:

pp uri_or_path
pp uri_or_path === URI::Generic
pp uri_or_path === URI::HTTP
pp uri_or_path === URI::HTTPS

and the result is

#<URI::Generic https://api.appstoreconnect.apple.com/v1/apps?>
false
false
false

which is somehow strange and I wonder how this will ever work.

I appreciate every clue on what's going on here.

@JohnReeze
Copy link

I've got the same issue. Crashes here

 Net::HTTP.start(uri.host, uri.port, net_http_options) do |http

As I see it, the problem is that uri.host == api.appstoreconnect.apple.com which may relate to absence of http// like here https://stackoverflow.com/questions/67367905/not-an-http-uri
But if I change this line to a valid https://api.appstoreconnect.apple.com string it still crashes with Failed to open TCP connection to https://api.appstoreconnect.apple.com/v1/apps: (getaddrinfo: nodename nor servname provided, or not known) so I guess it's more complicated error than I described)

@kyledecot
Copy link
Owner

👋 Thanks for reporting this. I was able to reproduce this using 0.38.0 from rubygems.org. It seems to be working as expected when using git main:

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'

  gem 'app_store_connect', github: 'kyledecot/app_store_connect@main'
end

require 'app_store_connect'

AppStoreConnect.config = {
  issuer_id: ENV["XCC_ISSUER_ID"],
  key_id: ENV["XCC_PRIVATE_KEY_ID"],
  private_key: ENV["XCC_PRIVATE_KEY"]
}

client = AppStoreConnect::Client.new

pp client.apps

Let me know if this fixes your issue and if so I'll release a new version of the gem.

@JohnReeze
Copy link

Specified in Gemfile and updated, but still facing same issue.
Screenshot 2024-06-10 at 13 22 48

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

3 participants