{"action":"created","issue":{"url":"https://api.github.com/repos/neumino/thinky/issues/315","labels_url":"https://api.github.com/repos/neumino/thinky/issues/315/labels{/name}","comments_url":"https://api.github.com/repos/neumino/thinky/issues/315/comments","events_url":"https://api.github.com/repos/neumino/thinky/issues/315/events","html_url":"https://github.com/neumino/thinky/issues/315","id":100706277,"number":315,"title":"Possibly unhandled TypeError: Cannot read property 'validate' when using model.post('retrieve')","user":{"login":"justingosan","id":943867,"avatar_url":"https://avatars.githubusercontent.com/u/943867?v=3","gravatar_id":"","url":"https://api.github.com/users/justingosan","html_url":"https://github.com/justingosan","followers_url":"https://api.github.com/users/justingosan/followers","following_url":"https://api.github.com/users/justingosan/following{/other_user}","gists_url":"https://api.github.com/users/justingosan/gists{/gist_id}","starred_url":"https://api.github.com/users/justingosan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justingosan/subscriptions","organizations_url":"https://api.github.com/users/justingosan/orgs","repos_url":"https://api.github.com/users/justingosan/repos","events_url":"https://api.github.com/users/justingosan/events{/privacy}","received_events_url":"https://api.github.com/users/justingosan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-13T07:23:54Z","updated_at":"2015-08-13T07:42:11Z","closed_at":null,"body":"Hi!\r\n\r\nWhenever I use:\r\n\r\n```\r\nmodel.post('retrieve', function(next) {\r\n        next();\r\n    });\r\n```\r\n...and try to query or create that model, I get this error\r\n```\r\nPossibly unhandled TypeError: Cannot read property 'validate' of undefined\r\n    at /Users/Justin/Projects/Node/project_name/node_modules/thinky/lib/model.js:897:36\r\n    at tryCatch1 (/Users/Justin/Projects/Node/project_name/node_modules/thinky/node_modules/bluebird/js/main/util.js:43:21)\r\n    at Promise$_callHandler [as _callHandler] (/Users/Justin/Projects/Node/project_name/node_modules/thinky/node_modules/bluebird/js/main/promise.js:627:13)\r\n    at Promise$_settlePromiseFromHandler [as _settlePromiseFromHandler] (/Users/Justin/Projects/Node/project_name/node_modules/thinky/node_modules/bluebird/js/main/promise.js:641:18)\r\n    at Promise$_settlePromiseAt [as _settlePromiseAt] (/Users/Justin/Projects/Node/project_name/node_modules/thinky/node_modules/bluebird/js/main/promise.js:800:14)\r\n    at Async$_consumeFunctionBuffer [as _consumeFunctionBuffer] (/Users/Justin/Projects/Node/project_name/node_modules/thinky/node_modules/bluebird/js/main/async.js:75:12)\r\n    at Async$consumeFunctionBuffer (/Users/Justin/Projects/Node/project_name/node_modules/thinky/node_modules/bluebird/js/main/async.js:38:14)\r\n    at process._tickDomainCallback (node.js:381:11)\r\n```\r\n\r\nHere's my model schema:\r\n```\r\nvar model = thinky.createModel('User', {\r\n        type: thinky.type.string().default('User'),\r\n        id: thinky.type.string(),\r\n        username: thinky.type.string(),\r\n        password: thinky.type.string(),\r\n        first_name: thinky.type.string(),\r\n        last_name: thinky.type.string(),\r\n        email: thinky.type.string(),\r\n        role: thinky.type.string(),\r\n        organization_id: thinky.type.string(),\r\n        date_modified: thinky.type.date().default(thinky.r.now()),\r\n        date_created: thinky.type.date().default(thinky.r.now()),\r\n        isDeleted: thinky.type.boolean().default(false)\r\n    }, {\r\n        enforce_extra: 'remove'\r\n    });\r\n\r\n    model.belongsTo(thinky.models.Organization, 'organization', 'organization_id', 'id');\r\n\r\n    model.pre('save', function(next){\r\n        this.date_modified = thinky.r.now();\r\n        next();\r\n    });\r\n\r\n    model.post('save', function(next) {\r\n        delete this.password;\r\n        next();\r\n    });\r\n\r\n    model.post('retrieve', function(next) {\r\n        delete this.password;\r\n        next();\r\n    });\r\n```\r\n\r\nThe Organization model simply contains a name (string) field.\r\nUsing thinky@2.1.1\r\n\r\nAny thoughts?"},"comment":{"url":"https://api.github.com/repos/neumino/thinky/issues/comments/130566405","html_url":"https://github.com/neumino/thinky/issues/315#issuecomment-130566405","issue_url":"https://api.github.com/repos/neumino/thinky/issues/315","id":130566405,"user":{"login":"neumino","id":1461947,"avatar_url":"https://avatars.githubusercontent.com/u/1461947?v=3","gravatar_id":"","url":"https://api.github.com/users/neumino","html_url":"https://github.com/neumino","followers_url":"https://api.github.com/users/neumino/followers","following_url":"https://api.github.com/users/neumino/following{/other_user}","gists_url":"https://api.github.com/users/neumino/gists{/gist_id}","starred_url":"https://api.github.com/users/neumino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neumino/subscriptions","organizations_url":"https://api.github.com/users/neumino/orgs","repos_url":"https://api.github.com/users/neumino/repos","events_url":"https://api.github.com/users/neumino/events{/privacy}","received_events_url":"https://api.github.com/users/neumino/received_events","type":"User","site_admin":false},"created_at":"2015-08-13T07:42:11Z","updated_at":"2015-08-13T07:42:11Z","body":"Using the query `model.run()` works fine too. I'm not sure how `data[i]` could be `undefined`. The only way would be that the `retrieve` hooks set `data[i]` to `undefined` but I don't see how that's possible."}}