-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
undefined method '[]' for nil:NilClass (NoMethodError) when getting state of previously terminated instance #1449
Comments
Taking a look, trying to reproduce ... |
@DenverJ I couldn't reproduce this error with latest SDK, I could see it responses correctly with either freshly terminated instances or an invalid id.
This is an expected behavior for recent terminated instance. So it would be great if you could provide more information, such as, is this causing errors everytime? or this only happens with terminated instances? Also, our #getting help section has been updated recently as well, feel free to get involved in channels : ). I'd be happy to dig deeper in to issue if you feel it might be a potential bug with our SDK. |
Yes, I would like to report this as a bug running version 2.8.3 I can reproduce this every time (the key being on an instance that has been terminated but AFTER it disappears from the console and the API). As I was trying to illustrate above, a describeInstances API call filtering on a recently terminated instance returns an object in the array just like filtering for a running instance would. After some time (~1hr) the describeInstances response returns an EMPTY array. So to recreate the issue...
|
@DenverJ Thanks for getting back! I'll try that again since the last time when I'm trying to reproduce, it's kind of freshly terminated : ) |
Here's a repro assuming the service returns as described: ec2.stub_responses(describe_instances: [{reservations: []}])
r = Aws::EC2::Resource.new(region: "us-east-1", client: ec2)
r.instance("i-123456789").state.name That returns the junk error. |
I can see that the EC2 resource definition seems to take for granted that reservations cannot be empty. How we can wrap this with a more user friendly exception in a general way is an interesting question. |
I have the same issue what was done to fix it ? |
You can always use client directly with API calls to workaround the issue. Tracking it as a resource model limitation at backlog, closing. |
Using this example code
I get an error like
E, [2017-03-08T16:02:01.299512 #31176] ERROR -- : undefined method `[]' for nil:NilClass (NoMethodError) C:/Dev/SDK/Ruby200/lib/ruby/gems/2.0.0/gems/aws-sdk-resources-2.6.3/lib/aws-sdk-resources/resource.rb:223:in `block in add_data_attribute'
When instance id 'i-abcdefgh123456789' is a previously terminated instance (but no longer visible via the API as being in a 'terminated' state).
It looks like the AWS API returns a different response for a valid instance id that was previously terminated vs an instance id that never existed in the account. See example API responses below.
Previously terminated instance...
Nonsense instance id that never existed in the account...
The text was updated successfully, but these errors were encountered: