{"action":"opened","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-golang/issues/216","repository_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-golang","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-golang/issues/216/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-golang/issues/216/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-golang/issues/216/events","html_url":"https://github.com/GoogleCloudPlatform/gcloud-golang/issues/216","id":136265751,"number":216,"title":"datastore.PutMulti fails when `src` is a slice of structs.","user":{"login":"campoy","id":2237452,"avatar_url":"https://avatars.githubusercontent.com/u/2237452?v=3","gravatar_id":"","url":"https://api.github.com/users/campoy","html_url":"https://github.com/campoy","followers_url":"https://api.github.com/users/campoy/followers","following_url":"https://api.github.com/users/campoy/following{/other_user}","gists_url":"https://api.github.com/users/campoy/gists{/gist_id}","starred_url":"https://api.github.com/users/campoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/campoy/subscriptions","organizations_url":"https://api.github.com/users/campoy/orgs","repos_url":"https://api.github.com/users/campoy/repos","events_url":"https://api.github.com/users/campoy/events{/privacy}","received_events_url":"https://api.github.com/users/campoy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-25T03:22:55Z","updated_at":"2016-02-25T03:22:55Z","closed_at":null,"body":"I've identified an error on one of my demos that came down to PutMulti failing with `datastore: invalid entity type` even though the equivalent code works when using the `google.golang.org/appengine/datastore` package.\r\n\r\nA program showing how this fail:\r\n\r\n```go\r\npackage main                                                                                                             \r\n                                                                                                                         \r\nimport (                                                                                                                 \r\n        \"log\"\r\n        \"net/http\"                                                                                                       \r\n        \r\n        \"golang.org/x/net/context\"\r\n\r\n        \"google.golang.org/appengine\"                                                                                    \r\n        \"google.golang.org/cloud\"                                                                                        \r\n        \"google.golang.org/cloud/datastore\"                                                                              \r\n)                                                                                                                        \r\n                                                                                                                         \r\nfunc main() {\r\n        http.HandleFunc(\"/\", handler)\r\n        appengine.Main()                                                                                                 \r\n}       \r\n        \r\nfunc handler(w http.ResponseWriter, r *http.Request) {                                                                   \r\n        ctx := cloud.NewContext(\"project-id\", http.DefaultClient)                                                          \r\n        \r\n        type Values struct{ Name string }\r\n        values := []Values{{\"one\"}, {\"two\"}, {\"three\"}}                                                                  \r\n        \r\n        var keys []*datastore.Key                                                                                        \r\n        for range values {\r\n                keys = append(keys, datastore.NewIncompleteKey(ctx, \"Value\", nil))                                       \r\n        }                                                                                                                \r\n\r\n        client, err := datastore.NewClient(ctx, \"project-id\")\r\n        if err != nil {\r\n                log.Fatal(err)\r\n        }\r\n\r\n        _, err = client.PutMulti(ctx, keys, values)\r\n        if err != nil {\r\n                http.Error(w, err.Error(), http.StatusInternalServerError)\r\n        }\r\n}\r\n```\r\n\r\nThe program will fail every time with the following message:\r\n\r\n```\r\ndatastore: Error while saving /Value,0: datastore: invalid entity type\r\n```\r\n\r\nEven though according to the specs the `src` argument to `PutMulti` must satisfy the same conditions as `dst` in `GetMulti`:\r\n\r\n\r\n> dst must be a []S, []*S, []I or []P, for some struct type S, some interface type I, or some non-interface \r\n> non-pointer type P such that P or *P implements PropertyLoadSaver. If an []I, each element must be \r\n> a valid dst for Get: it must be a struct pointer or implement PropertyLoadSaver.\r\n\r\nAccording to my understanding, `values` is a slice of struct values therefore `[]S`. By modifying the program above so `values` is of type `[]*Value` the program works.\r\n\r\nAdditionally, this appengine version works correctly:\r\n\r\n```go\r\npackage test                                                                                                             \r\n                                                                                                                         \r\nimport (                                                                                                                 \r\n        \"net/http\"\r\n        \r\n        \"google.golang.org/appengine\"\r\n        \"google.golang.org/appengine/datastore\"\r\n)\r\n        \r\nfunc init() {\r\n        http.HandleFunc(\"/\", handler)\r\n}                                                                                                                        \r\n                                                                                                                         \r\nfunc handler(w http.ResponseWriter, r *http.Request) {\r\n        ctx := appengine.NewContext(r)\r\n        \r\n        type Values struct{ Name string }\r\n        values := []Values{{\"one\"}, {\"two\"}, {\"three\"}}\r\n\r\n        var keys []*datastore.Key\r\n        for range values {\r\n                keys = append(keys, datastore.NewIncompleteKey(ctx, \"Value\", nil))\r\n        }\r\n        _, err := datastore.PutMulti(ctx, keys, values)\r\n        if err != nil {\r\n                http.Error(w, err.Error(), http.StatusInternalServerError)\r\n        }       \r\n}       \r\n```"}}