This project is archived and is in readonly mode.
[PATCH] json validations errors for ActiveResource
-
Fabien Jakimowicz
Patch updated for current rails version.
-
Fabien Jakimowicz
- Tag changed from activeresource, json, patch, validations to activeresource, active_resource, json, patch, validations
-
Fabien Jakimowicz
- Tag changed from activeresource, active_resource, json, patch, validations to activeresource, active_resource, json, patch, validation, validations
-
Fabien Jakimowicz
- Tag changed from activeresource, active_resource, json, patch, validation, validations to 2-3-stable, activeresource, active_resource, json, patch, validation, validations
updated patch for 2-3-stable branch.
-
Samsonov Ivan
Our company faces the same problem. Why is this patch not accepted?
-
Fabien Jakimowicz
I tried to contact rails-core mailing list, but nobody answers. I also try to contact directly a member of the rails-core team who told me the patch seems good and should be applied within 2 weeks ... but that was 2 months ago and he does not answer me anymore.
I checked with both 2.3 and 3.0 branches and it still applies cleanly.
Maybe if you can move things on the mailing list, you can have this patch applied.
-
Fabien Jakimowicz
- Tag changed from 2-3-stable, activeresource, active_resource, json, patch, validation, validations to 2-3-stable, 2.3.x, 2.x, 3.0, activeresource, active_resource, json, patch, validation, validations
-
Rizwan Reza
- Tag changed from 2-3-stable, 2.3.x, 2.x, 3.0, activeresource, active_resource, json, patch, validation, validations to 2-3-stable, 2.3.x, 2.x, 3.0, activeresource, active_resource, bugmash, json, patch, validation, validations
verified
+1 This applies to 2-3-stable cleanly but not master.
-
Rizwan Reza
The tests pass too.
-
Elad Meidar
Patch applies and tests pass on 2-3-stable
Patch does not apply on master.
-
Fabien Jakimowicz
I updated patch for both 2-3-stable and master branches.
-
Fabien Jakimowicz
- Title changed from json validations errors for ActiveResource to [PATCH] json validations errors for ActiveResource
-
Elad Meidar
+1 Verified, +1 on 2-3-stable patch => applies and all tests pass, +1 on master patch => applies and all tests pass
-
Simon Jefford
+1 verified on both stable and master.
-
David Trasbo
-1
Both patches don't apply and needs to be updated respectively.
-
Fabien Jakimowicz
david trasbo: this is weird, I just test it and was able to apply it to both branches. How does it fail ?
-
Nathan Humbert
+1 on 2-3-stable patch => applies and all tests pass
-
Josh Nichols
+1, I like the cut of this patch, for it brings consistency between xml and json behavior with regards to validation errors.
Verified to apply and pass tests on master and 2-3-stable.
-
Repository
- State changed from new to committed
(from [797588543ed70b4c5dcf51d7f1e4a77082172f0b]) Add support for errors in JSON format.
[#1956 [PATCH] json validations errors for ActiveResource state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/797588543ed70b4c5dcf51d7f1e4a7... -
Repository
(from [c3da22c042d083b788fd35ce7a25e3d8933bcae6]) Add support for errors in JSON format.
[#1956 [PATCH] json validations errors for ActiveResource state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/c3da22c042d083b788fd35ce7a25e3... -
Jeremy Kemper
- Tag changed from 2-3-stable, 2.3.x, 2.x, 3.0, activeresource, active_resource, bugmash, json, patch, validation, validations to 2-3-stable, 2.3.x, 2.x, 3.0, activeresource, active_resource, json, patch, validation, validations
- Milestone changed from 2.x to 2.3.4
-
Jeremy Kemper
- Milestone changed from 2.3.4 to 2.3.6
- State changed from committed to open
- Assigned user set to Jeremy Kemper
A change to ActiveResource::Validations was introduced in 2.3.4 which adds support for JSON errors:
This is looking for an exact match on Content-Type 'application/xml'. If, for example, the returned Content-Type is 'application/xml; charset=utf-8' then the error response is ignored.
-
Repository
- State changed from open to committed
(from [1488c6cc9e6237ce794e3c4a6201627b9fd4ca09]) Fix brittle content-type check. [#1956 [PATCH] json validations errors for ActiveResource state:committed] http://github.com/rails/rails/commit/1488c6cc9e6237ce794e3c4a620162...
-
Repository
(from [b5dd1b659987bb6117c0f1657e66dc395cfbed5e]) Fix brittle content-type check. [#1956 [PATCH] json validations errors for ActiveResource state:committed] http://github.com/rails/rails/commit/b5dd1b659987bb6117c0f1657e66dc...
-
Gabe da Silveira
This patch introduced a regression my app's tests because our activeresource mocks did not set a content-type header. This was easy enough to fix once I debugged it, but it was pretty nasty to track down since the result is simply that the error messages are ignored and save returns true and the object appears valid with no trace of what happened without debugging deep into ActiveResource. Even though in production this case ought to never happen, in tests it's the default with no indication that you would need to set a Content-Type header.
The bottom line in my opinion is that any case where a 422 response is returned, the object should end up as invalid.
Although I'm not sure that defaulting to XML is "correct" or complete, I think we should do it to maintain backwards compatibility.
At the very least the ActiveResource::HttpMock documentation should show an example of stubbing an error.
What does everyone think?
-
James Brennan
ticket #3386 ActiveResource not picking up (validation) errors in 2.3.4 is a duplicate of the regression
-
Jatinder Singh
To avoid the problem faced by Gabe, the solution is to verify the format of ARes rather than Content-Type header for the remote errors.
I've attached patches for master and 2-3-stable.
-
Christian Seiler
Another (slightly) related problem with ActiveResource and validations:
https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets... -
Jatinder Singh
Alright I've attached patches for master and 2-3-stable, with tests.
-
Repository
- State changed from incomplete to committed
(from [158e7b63ab83dbcb9cdc7f951be920faf16fe3c0]) Use format of ARes rather than content-type of remote errors to load errors.
[#1956 [PATCH] json validations errors for ActiveResource state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/158e7b63ab83dbcb9cdc7f951be920... -
Repository
(from [e87748869af238fe6bcb78e8d9a8d2bbc3734039]) Use format of ARes rather than content-type of remote errors to load errors.
[#1956 [PATCH] json validations errors for ActiveResource state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/e87748869af238fe6bcb78e8d9a8d2...
