hakanensari / jeff Goto Github PK
View Code? Open in Web Editor NEWMinimum-viable Amazon Web Services client
License: MIT License
Minimum-viable Amazon Web Services client
License: MIT License
Hello, Hakan
I need to use ItemLookup query. Simply find by ItemId. So I'm building simple request like
2.1.2 :044 > req
=> #<Vacuum::Request:0x000000029d96b0 @aws_endpoint="http://webservices.amazon.com/onca/xml", @aws_access_key_id="MYAWESOMEKEYID", @aws_secret_access_key="andmyawesomesecretkey", @connection=#<Excon::Connection:29c0570 @data={:chunk_size=>1048576, :ciphers=>"HIGH:!SSLv2:!aNULL:!eNULL:!3DES", :connect_timeout=>60, :debug_request=>false, :debug_response=>false, :headers=>{"User-Agent"=>"Jeff/1.3.0 (Language=Ruby; X55VD)"}, :idempotent=>false, :instrumentor_name=>"excon", :middlewares=>[Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock], :mock=>false, :nonblock=>true, :omit_default_port=>true, :persistent=>false, :read_timeout=>60, :retry_limit=>4, :ssl_verify_peer=>true, :tcp_nodelay=>false, :thread_safe_sockets=>true, :uri_parser=>URI, :versions=>"excon/0.45.3 (x86_64-linux) ruby/2.1.2", :write_timeout=>60, :host=>"webservices.amazon.com", :hostname=>"webservices.amazon.com", :path=>"/onca/xml", :port=>80, :query=>nil, :scheme=>"http", :expects=>200} @socket_key="http://webservices.amazon.com">>
And send
response = req.item_lookup(query: { 'ItemId' => '9785845917461' })
And got
Excon::Errors::BadRequest: Expected(200) <=> Actual(400 Bad Request)
It seems credentials are valid, otherwise Response code would be 403
I also tried different params and another queries, but got the same response.
So I hope you can help me with that. Thank you.
I've been looking into changes needed to migrate to new API and there is this line in Features section
Requests are signed with the more secure and recommended signature version 4 signing process over signature version 2.
There is a bit more info on how this new method of signature works here:
https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
Since my project depends on this library. I identified this as a great starting point to migrate to v5. I'll try to provide changes in a separate pull request.
RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.
There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.
I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!
Appendix:
If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies
p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.
I thought I'd open this issue because Jeff requires Excon of specified versions. I use a2z which uses Jeff and a nice use case is caching all requests that go to Amazon so I don't burn through my quota while doing testing. VCR solves this problem nicely by watching for Excon requests and caches them to yaml. Maybe you know about VCR already. ๐
I'm pretty sure this isn't your problem, so you can close this issue if it is off-topic of outside your boundary but I thought I'd mention it here anyway since Excon seems to be making some major changes lately? and maybe this might impact your gemspec.
When I used Excon 0.20.1 with a combination of jeff 0.5.0+ then I would get this
NoMethodError:
undefined method `connection' for #<Excon::Connection:0x007f9c45c4c488>
# (eval):3:in `get'
But when I roll back to jeff 0.4.3 + Excon 0.16.10, things work with no errors. I am wrapping jeff and a2z in a VCR trying to cache the call to amazon. So my stack looks something like this:
VCR caching block
my code calls a2z
a2z uses jeff for the amazon signature, and uses excon for transport
end
I don't believe a2z actually uses excon directly or any other http client.
Since my above explanation is pretty ๐ฉ, I have reproduced the problem with as little code as possible below.
Here is the Gemfile I used. Be sure to swap out 0.5.0 with the commented line 0.4.3. Any Jeff gem newer than 0.4.3 (0.6.0 and 0.6.1) exhibit the problem.
# Gemfile
source "https://rubygems.org"
gem 'jeff', '= 0.5.0'
# gem 'jeff', '= 0.4.3'
gem 'vcr'
gem 'rspec'
Run the following after bundle with bundle exec reproduce.rb
to use the flip-flopped jeff gem.
# reproduce.rb
# reproduce an issue with newer versions of jeff and vcr
require 'minitest/autorun'
require 'jeff'
require 'vcr'
require 'net/http'
VCR.configure do |c|
c.cassette_library_dir = 'cassettes'
c.hook_into :excon
end
class Foo
include Jeff
def initialize
@endpoint = "http://localhost"
end
end
describe Foo do
def setup
@subject = Foo.new
end
it 'does stuff' do
VCR.use_cassette('synopsis') do
@subject.connection
end
end
end
When this above reproduce.rb runs with 0.4.3 it works:
be ruby reproduce.rb
Run options: --seed 60054
# Running tests:
.
Finished tests in 0.001531s, 653.1679 tests/s, 0.0000 assertions/s.
When it fails:
1) Error:
test_0001_does_stuff(Foo):
NoMethodError: undefined method `connection' for #<Excon::Connection:0x007fb8c1479ba0>
gems/vcr-2.4.0/lib/vcr/library_hooks/excon.rb:182:in `block in new'
gems/vcr-2.4.0/lib/vcr/library_hooks/excon.rb:181:in `tap'
gems/vcr-2.4.0/lib/vcr/library_hooks/excon.rb:181:in `new'
gems/excon-0.20.1/lib/excon.rb:123:in `new'
gems/ruby-1.9.3-p385@oss_contrib/gems/jeff-0.6.1/lib/jeff.rb:49:in `connection'
reproduce.rb:28:in `block (3 levels) in <main>'
gems/ruby-1.9.3-p385@oss_contrib/gems/vcr-2.4.0/lib/vcr/util/variable_args_block_caller.rb:9:in `call'
gems/ruby-1.9.3-p385@oss_contrib/gems/vcr-2.4.0/lib/vcr/util/variable_args_block_caller.rb:9:in `call_block'
gems/ruby-1.9.3-p385@oss_contrib/gems/vcr-2.4.0/lib/vcr.rb:173:in `use_cassette'
reproduce.rb:27:in `block (2 levels) in <main>'
(i have snipped some things in the stacktrace above)
VCR even warns:
You are using Excon 0.20.1. VCR is known to work with Excon >= 0.9.6, < 0.17. It may not work with this version.
But the version of Excon is required by Jeff. That's ok. I rolled back to 0.4.3 and now I can cache Jeff signed amazon requests with VCR and all is happy.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.