{"action":"created","issue":{"url":"https://api.github.com/repos/boto/boto3/issues/625","repository_url":"https://api.github.com/repos/boto/boto3","labels_url":"https://api.github.com/repos/boto/boto3/issues/625/labels{/name}","comments_url":"https://api.github.com/repos/boto/boto3/issues/625/comments","events_url":"https://api.github.com/repos/boto/boto3/issues/625/events","html_url":"https://github.com/boto/boto3/issues/625","id":153564997,"node_id":"MDU6SXNzdWUxNTM1NjQ5OTc=","number":625,"title":"ec2 Instance object doesn't handle None reservations gracefully","user":{"login":"dpantke","id":5297213,"node_id":"MDQ6VXNlcjUyOTcyMTM=","avatar_url":"https://avatars2.githubusercontent.com/u/5297213?v=4","gravatar_id":"","url":"https://api.github.com/users/dpantke","html_url":"https://github.com/dpantke","followers_url":"https://api.github.com/users/dpantke/followers","following_url":"https://api.github.com/users/dpantke/following{/other_user}","gists_url":"https://api.github.com/users/dpantke/gists{/gist_id}","starred_url":"https://api.github.com/users/dpantke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpantke/subscriptions","organizations_url":"https://api.github.com/users/dpantke/orgs","repos_url":"https://api.github.com/users/dpantke/repos","events_url":"https://api.github.com/users/dpantke/events{/privacy}","received_events_url":"https://api.github.com/users/dpantke/received_events","type":"User","site_admin":false},"labels":[{"id":281751517,"node_id":"MDU6TGFiZWwyODE3NTE1MTc=","url":"https://api.github.com/repos/boto/boto3/labels/ec2","name":"ec2","color":"eb6420","default":false},{"id":308772252,"node_id":"MDU6TGFiZWwzMDg3NzIyNTI=","url":"https://api.github.com/repos/boto/boto3/labels/resource%20model","name":"resource model","color":"f7c6c7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-05-07T01:18:09Z","updated_at":"2018-06-19T00:12:22Z","closed_at":null,"author_association":"NONE","body":"When you call the DescribeInstances AWS API call and give it a list of instances, if that instance was terminated some time ago, AWS in some cases may not return a InvalidInstanceID.NotFound; instead, it will return a valid response but with an empty reservations list. When this happens, boto3 does the object mapping as expected, but accessing any attribute on an ec2 instance in this state results in:\n\n```\n  File \"/Library/Python/2.7/site-packages/boto3/resources/factory.py\", line 345, in property_loader\n    return self.meta.data.get(name)\nAttributeError: 'NoneType' object has no attribute 'get'\n```\n\nThis can be reproduced by executing the following on an instance ID that once existed, but has been terminated for a day or so:\n\n```\nimport boto3\nbad_iid = \"i-1234567\"\nec2 = boto3.Session().resource(\"ec2\")\ninstance = ec2.Instance(bad_iid)\nprint i.launch_time\n```\n\nI see 2 ways of fixing this problem:\n1. Catching the fact that reservations are empty and issuing spontaneous InvalidInstanceID.NotFound ourselves.\n2. Expose the reservation ID as part of the Instance object so that callers can check the reservation for themselves before attempting to access other Instance attributes.\n\nI would much prefer solution #1 as empty reservations and InvalidInstanceID.NotFound are really the same thing, and I can't think of any possible scenario where a developer would ever need to distinguish between the 2 not found scenarios (and if they needed that detail they should probably be calling describe_instances directly and examining the contents of the dict.)\n"},"comment":{"url":"https://api.github.com/repos/boto/boto3/issues/comments/398234064","html_url":"https://github.com/boto/boto3/issues/625#issuecomment-398234064","issue_url":"https://api.github.com/repos/boto/boto3/issues/625","id":398234064,"node_id":"MDEyOklzc3VlQ29tbWVudDM5ODIzNDA2NA==","user":{"login":"adrienkohlbecker","id":70469,"node_id":"MDQ6VXNlcjcwNDY5","avatar_url":"https://avatars0.githubusercontent.com/u/70469?v=4","gravatar_id":"","url":"https://api.github.com/users/adrienkohlbecker","html_url":"https://github.com/adrienkohlbecker","followers_url":"https://api.github.com/users/adrienkohlbecker/followers","following_url":"https://api.github.com/users/adrienkohlbecker/following{/other_user}","gists_url":"https://api.github.com/users/adrienkohlbecker/gists{/gist_id}","starred_url":"https://api.github.com/users/adrienkohlbecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adrienkohlbecker/subscriptions","organizations_url":"https://api.github.com/users/adrienkohlbecker/orgs","repos_url":"https://api.github.com/users/adrienkohlbecker/repos","events_url":"https://api.github.com/users/adrienkohlbecker/events{/privacy}","received_events_url":"https://api.github.com/users/adrienkohlbecker/received_events","type":"User","site_admin":false},"created_at":"2018-06-19T00:12:22Z","updated_at":"2018-06-19T00:12:22Z","author_association":"NONE","body":"Digging up this issue as I just hit it"}}
{"actor":{"display_login":"adrienkohlbecker"}}