{"action":"created","issue":{"url":"https://api.github.com/repos/awslabs/aws-sdk-go/issues/110","labels_url":"https://api.github.com/repos/awslabs/aws-sdk-go/issues/110/labels{/name}","comments_url":"https://api.github.com/repos/awslabs/aws-sdk-go/issues/110/comments","events_url":"https://api.github.com/repos/awslabs/aws-sdk-go/issues/110/events","html_url":"https://github.com/awslabs/aws-sdk-go/issues/110","id":58107432,"number":110,"title":"Panic on ec2.ImportKeyPair","user":{"login":"catsby","id":61721,"avatar_url":"https://avatars.githubusercontent.com/u/61721?v=3","gravatar_id":"","url":"https://api.github.com/users/catsby","html_url":"https://github.com/catsby","followers_url":"https://api.github.com/users/catsby/followers","following_url":"https://api.github.com/users/catsby/following{/other_user}","gists_url":"https://api.github.com/users/catsby/gists{/gist_id}","starred_url":"https://api.github.com/users/catsby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/catsby/subscriptions","organizations_url":"https://api.github.com/users/catsby/orgs","repos_url":"https://api.github.com/users/catsby/repos","events_url":"https://api.github.com/users/catsby/events{/privacy}","received_events_url":"https://api.github.com/users/catsby/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/awslabs/aws-sdk-go/labels/fixed-in-develop","name":"fixed-in-develop","color":"fbca04"},{"url":"https://api.github.com/repos/awslabs/aws-sdk-go/labels/master","name":"master","color":"bfd4f2"},{"url":"https://api.github.com/repos/awslabs/aws-sdk-go/labels/protocol","name":"protocol","color":"fef2c0"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/awslabs/aws-sdk-go/milestones/1","html_url":"https://github.com/awslabs/aws-sdk-go/milestones/Merge%20develop%20into%20master","labels_url":"https://api.github.com/repos/awslabs/aws-sdk-go/milestones/1/labels","id":1021784,"number":1,"title":"Merge develop into master","description":"Currently, development work is happening in the `develop` branch in order to refactor some internals without breaking the current API in master. This milestone will track any issues that are addressed in the develop branch and should be resolved once the branch is merged.\r\n\r\nNote that breaking API changes will come with the merge of develop into master.","creator":{"login":"lsegal","id":686,"avatar_url":"https://avatars.githubusercontent.com/u/686?v=3","gravatar_id":"","url":"https://api.github.com/users/lsegal","html_url":"https://github.com/lsegal","followers_url":"https://api.github.com/users/lsegal/followers","following_url":"https://api.github.com/users/lsegal/following{/other_user}","gists_url":"https://api.github.com/users/lsegal/gists{/gist_id}","starred_url":"https://api.github.com/users/lsegal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsegal/subscriptions","organizations_url":"https://api.github.com/users/lsegal/orgs","repos_url":"https://api.github.com/users/lsegal/repos","events_url":"https://api.github.com/users/lsegal/events{/privacy}","received_events_url":"https://api.github.com/users/lsegal/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":13,"state":"open","created_at":"2015-03-15T00:35:40Z","updated_at":"2015-03-26T19:56:30Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-02-18T18:28:14Z","updated_at":"2015-03-26T19:56:30Z","closed_at":"2015-03-26T19:56:30Z","body":"I'm trying to import a new keypair, but I'm getting the following panic:\r\n\r\n    panic: reflect: call of reflect.Value.NumField on uint8 Value\r\n\r\nHere's a sample script to reproduce:\r\n\r\n`main.go`:\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"flag\"\r\n\t\"fmt\"\r\n\r\n\t\"github.com/awslabs/aws-sdk-go/aws\"\r\n\t\"github.com/awslabs/aws-sdk-go/gen/ec2\"\r\n)\r\n\r\nvar accessKey = flag.String(\"accessKey\", \"meh\", \"access key\")\r\nvar secretKey = flag.String(\"secretKey\", \"nil\", \"secret key\")\r\n\r\nfunc main() {\r\n\tfmt.Println(\"Starting...\\n\")\r\n\tflag.Parse()\r\n\tcreds := aws.Creds(*accessKey, *secretKey, \"\")\r\n\tcli := ec2.New(creds, \"us-west-2\", nil)\r\n\r\n\tfmt.Println(\"Confirming anything works:\")\r\n\tresp, err := cli.DescribeRegions(nil)\r\n\tfmt.Println(\"First Region:\", *resp.Regions[0].RegionName) // prints something like 'eu-central-1'\r\n\tfmt.Println(\"err:\", err)\r\n\r\n\tfmt.Println(\"\\nImporting key:\")\r\n\tpublicKey := \"ssh-rsa XXXXX8a6f8dsa34fd5s6a4XXXXX clint@anemailaddress.com\"\r\n\treq := &ec2.ImportKeyPairRequest{\r\n\t\tKeyName:           aws.String(\"testname\"),\r\n\t\tPublicKeyMaterial: []byte(publicKey),\r\n\t}\r\n\tfmt.Println(\"\\n---Got to here--\\n\")\r\n\timportResp, err := cli.ImportKeyPair(req) // panics\r\n\tif err != nil {\r\n\t\tfmt.Errorf(\"Error import KeyPair: %s\", err)\r\n\t}\r\n\tfmt.Println(\"worked:\\n%#v\", importResp)\r\n}\r\n\r\n``` \r\n\r\nHere's the result:\r\n\r\n```console\r\n$ go get -u github.com/awslabs/aws-sdk-go/aws\r\n$ go get -u github.com/awslabs/aws-sdk-go/gen/ec2\r\n\r\n$ go run main.go -accessKey=xxxx -secretKey=xxxx\r\nStarting...\r\n\r\nConfirming anything works:\r\nFirst Region: eu-central-1\r\nerr: <nil>\r\n\r\nImporting key:\r\n\r\n---Got to here--\r\n\r\npanic: reflect: call of reflect.Value.NumField on uint8 Value\r\n\r\ngoroutine 1 [running]:\r\nreflect.flag.mustBe(0x48, 0x19)\r\n\t/usr/local/go/src/reflect/value.go:195 +0x92\r\nreflect.Value.NumField(0x1fbc20, 0x1199a4d5, 0x48, 0x48db18)\r\n\t/usr/local/go/src/reflect/value.go:1117 +0x2a\r\ngithub.com/awslabs/aws-sdk-go/aws.(*EC2Client).loadStruct(0x1193a1b0, 0x11b386a0, 0x1fbc20, 0x1199a4d5, 0x48, 0x11b386c0, 0x13, 0x0, 0x0)\r\n\t/Users/clint/Projects/Go/src/github.com/awslabs/aws-sdk-go/aws/ec2.go:123 +0xe0\r\ngithub.com/awslabs/aws-sdk-go/aws.(*EC2Client).loadValues(0x1193a1b0, 0x11b386a0, 0x1fbc20, 0x1199a4d5, 0x11b386c0, 0x13, 0x0, 0x0)\r\n\t/Users/clint/Projects/Go/src/github.com/awslabs/aws-sdk-go/aws/ec2.go:114 +0x283\r\ngithub.com/awslabs/aws-sdk-go/aws.(*EC2Client).loadValues(0x1193a1b0, 0x11b386a0, 0x1f4fa0, 0x1199a500, 0x2f7eed, 0x11, 0x0, 0x0)\r\n\t/Users/clint/Projects/Go/src/github.com/awslabs/aws-sdk-go/aws/ec2.go:107 +0x1a5\r\ngithub.com/awslabs/aws-sdk-go/aws.(*EC2Client).loadStruct(0x1193a1b0, 0x11b386a0, 0x25c220, 0x11b38680, 0xd9, 0x0, 0x0, 0x0, 0x0)\r\n\t/Users/clint/Projects/Go/src/github.com/awslabs/aws-sdk-go/aws/ec2.go:170 +0x77f\r\ngithub.com/awslabs/aws-sdk-go/aws.(*EC2Client).loadValues(0x1193a1b0, 0x11b386a0, 0x1ea260, 0x11b38680, 0x0, 0x0, 0x0, 0x0)\r\n\t/Users/clint/Projects/Go/src/github.com/awslabs/aws-sdk-go/aws/ec2.go:114 +0x283\r\ngithub.com/awslabs/aws-sdk-go/aws.(*EC2Client).Do(0x1193a1b0, 0x2a4ca8, 0xd, 0x28e078, 0x4, 0x288f68, 0x1, 0x1ea260, 0x11b38680, 0x1ea2a0, ...)\r\n\t/Users/clint/Projects/Go/src/github.com/awslabs/aws-sdk-go/aws/ec2.go:27 +0x1dc\r\ngithub.com/awslabs/aws-sdk-go/gen/ec2.(*EC2).ImportKeyPair(0x1191c338, 0x11b38680, 0x11a2f1e8, 0x0, 0x0)\r\n\t/Users/clint/Projects/Go/src/github.com/awslabs/aws-sdk-go/gen/ec2/ec2.go:1700 +0xa4\r\nmain.main()\r\n\t/Users/clint/Projects/main.go:32 +0x73a\r\n\r\ngoroutine 9 [runnable]:\r\nnet/http.(*persistConn).readLoop(0x1193e660)\r\n\t/usr/local/go/src/net/http/transport.go:928 +0x7b4\r\ncreated by net/http.(*Transport).dialConn\r\n\t/usr/local/go/src/net/http/transport.go:660 +0xa3f\r\n\r\ngoroutine 17 [syscall, locked to thread]:\r\nruntime.goexit()\r\n\t/usr/local/go/src/runtime/asm_386.s:2287 +0x1\r\n\r\ngoroutine 10 [select]:\r\nnet/http.(*persistConn).writeLoop(0x1193e660)\r\n\t/usr/local/go/src/net/http/transport.go:945 +0x314\r\ncreated by net/http.(*Transport).dialConn\r\n\t/usr/local/go/src/net/http/transport.go:661 +0xa54\r\nexit status 2\r\n```\r\n\r\nFrom what I can tell, it's happening in `aws/ec2 loadStruct`:\r\n\r\n- https://github.com/awslabs/aws-sdk-go/blob/master/aws/ec2.go#L117\r\n\r\nI'm not entirely sure what's happening with the usage of reflect there; if anyone has any ideas I'd love to help patch."},"comment":{"url":"https://api.github.com/repos/awslabs/aws-sdk-go/issues/comments/86689983","html_url":"https://github.com/awslabs/aws-sdk-go/issues/110#issuecomment-86689983","issue_url":"https://api.github.com/repos/awslabs/aws-sdk-go/issues/110","id":86689983,"user":{"login":"lsegal","id":686,"avatar_url":"https://avatars.githubusercontent.com/u/686?v=3","gravatar_id":"","url":"https://api.github.com/users/lsegal","html_url":"https://github.com/lsegal","followers_url":"https://api.github.com/users/lsegal/followers","following_url":"https://api.github.com/users/lsegal/following{/other_user}","gists_url":"https://api.github.com/users/lsegal/gists{/gist_id}","starred_url":"https://api.github.com/users/lsegal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsegal/subscriptions","organizations_url":"https://api.github.com/users/lsegal/orgs","repos_url":"https://api.github.com/users/lsegal/repos","events_url":"https://api.github.com/users/lsegal/events{/privacy}","received_events_url":"https://api.github.com/users/lsegal/received_events","type":"User","site_admin":false},"created_at":"2015-03-26T19:56:30Z","updated_at":"2015-03-26T19:56:30Z","body":"Develop was merged into master today, so I am marking this as closed since it *should* be resolved by the new implementation. Thanks for reporting! Feel free to re-open if you still run into this issue."}}