{"action":"created","issue":{"url":"https://api.github.com/repos/emberjs/data/issues/3893","labels_url":"https://api.github.com/repos/emberjs/data/issues/3893/labels{/name}","comments_url":"https://api.github.com/repos/emberjs/data/issues/3893/comments","events_url":"https://api.github.com/repos/emberjs/data/issues/3893/events","html_url":"https://github.com/emberjs/data/issues/3893","id":113867522,"number":3893,"title":"JSON API Errors Object","user":{"login":"sescobb27","id":1157892,"avatar_url":"https://avatars.githubusercontent.com/u/1157892?v=3","gravatar_id":"","url":"https://api.github.com/users/sescobb27","html_url":"https://github.com/sescobb27","followers_url":"https://api.github.com/users/sescobb27/followers","following_url":"https://api.github.com/users/sescobb27/following{/other_user}","gists_url":"https://api.github.com/users/sescobb27/gists{/gist_id}","starred_url":"https://api.github.com/users/sescobb27/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sescobb27/subscriptions","organizations_url":"https://api.github.com/users/sescobb27/orgs","repos_url":"https://api.github.com/users/sescobb27/repos","events_url":"https://api.github.com/users/sescobb27/events{/privacy}","received_events_url":"https://api.github.com/users/sescobb27/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":26,"created_at":"2015-10-28T16:55:48Z","updated_at":"2015-11-04T22:59:23Z","closed_at":null,"body":"Hi, we are migrating to Ember 1.13 and Ember Data 1.13 but we are having issues with JSON API error objects in tests:\r\n\r\n```js\r\ntest('Error on contact us form submition', function (assert) {\r\n  server.respondWith('POST', apiUrl + '/customer-supports', function (xhr) {\r\n    xhr.respond(422, {\r\n      'Content-Type': 'application/vnd.api+json'\r\n    }, JSON.stringify({\r\n      errors: [\r\n        {\r\n          status: '422',\r\n          title: 'Error Sending Email, Please try again!!!',\r\n          detail: 'Error Sending Email, Please try again!!!',\r\n          source: {\r\n            pointer: 'data/attributes/email'\r\n          }\r\n        }\r\n      ]\r\n    }));\r\n  });\r\n```\r\n```js\r\nimport Ember from 'ember';\r\n\r\nexport default Ember.Route.extend({\r\n  actions: {\r\n    contactUsFormSubmit: function () {\r\n      customerSupport.save().catch((error) => {\r\n        console.log(error);\r\n      });\r\n    }\r\n  }\r\n});\r\n```\r\n\r\n```\r\nTypeError: ember$data$lib$system$model$internal$model$$get(...).add is not a function\r\n    at InternalModel.ember$data$lib$system$model$internal$model$$InternalModel.addErrorMessageToAttribute (http://localhost:4200/assets/vendor.js:100040:75)\r\n    at InternalModel.ember$data$lib$system$model$internal$model$$InternalModel.adapterDidInvalidate (http://localhost:4200/assets/vendor.js:100064:18)\r\n    at ember$data$lib$system$store$$Service.extend.recordWasInvalid (http://localhost:4200/assets/vendor.js:101615:23)\r\n    at http://localhost:4200/assets/vendor.js:102349:17\r\n    at tryCatch (http://localhost:4200/assets/vendor.js:67605:14)\r\n    at invokeCallback (http://localhost:4200/assets/vendor.js:67620:15)\r\n    at publish (http://localhost:4200/assets/vendor.js:67588:9)\r\n    at publishRejection (http://localhost:4200/assets/vendor.js:67522:5)\r\n    at http://localhost:4200/assets/vendor.js:43997:7\r\n    at Queue.invoke (http://localhost:4200/assets/vendor.js:11505:16)\r\n```\r\n\r\nthe exception is thrown in `internal-model.js` when doing `get(record, 'errors').add(attribute, message);` in which record is equal to `customerSupport` model, `attribute` is equal to `email` and message is equal to ` 'Error Sending Email, Please try again!!!'`\r\n\r\n```js\r\n  addErrorMessageToAttribute: function (attribute, message) {\r\n    var record = this.getRecord();\r\n    get(record, 'errors').add(attribute, message);\r\n  },\r\n```\r\n\r\nwhat are we doing wrong? thanks"},"comment":{"url":"https://api.github.com/repos/emberjs/data/issues/comments/153896758","html_url":"https://github.com/emberjs/data/issues/3893#issuecomment-153896758","issue_url":"https://api.github.com/repos/emberjs/data/issues/3893","id":153896758,"user":{"login":"bcardarella","id":18524,"avatar_url":"https://avatars.githubusercontent.com/u/18524?v=3","gravatar_id":"","url":"https://api.github.com/users/bcardarella","html_url":"https://github.com/bcardarella","followers_url":"https://api.github.com/users/bcardarella/followers","following_url":"https://api.github.com/users/bcardarella/following{/other_user}","gists_url":"https://api.github.com/users/bcardarella/gists{/gist_id}","starred_url":"https://api.github.com/users/bcardarella/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcardarella/subscriptions","organizations_url":"https://api.github.com/users/bcardarella/orgs","repos_url":"https://api.github.com/users/bcardarella/repos","events_url":"https://api.github.com/users/bcardarella/events{/privacy}","received_events_url":"https://api.github.com/users/bcardarella/received_events","type":"User","site_admin":false},"created_at":"2015-11-04T22:59:23Z","updated_at":"2015-11-04T22:59:23Z","body":"@drspaniel you could make that case for pretty much every piece of public API"}}