Skip Menu |

This queue is for tickets about the CatalystX-ExtJS CPAN distribution.

Report information
The Basics
Id: 60686
Status: resolved
Priority: 0/
Queue: CatalystX-ExtJS

People
Owner: Nobody in particular
Requestors: mail [...] herbert-leitz.de
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.120000
Fixed in: (no value)



Subject: No CRUD errors in Ext.Direct [PATCH]
Hi, CRUD errors in C::C..ExtJS::REST ('Object could not be found' etc) set the HTTP status code via $self->status_not_found. In C::C::ExtJS::Direct::API the status code is ignored and the error is returned as a plain message in the JSON response with status 200. Unfortunately ExtJS sees this as a success. No error is reported and the store and the database get out of sync. There are two possibilities to fix this: 1. return {'success': false} for each failed request 2. return an exception for each failed request I choose alternative 2 for the patch because it's easier (just two additional lines). The error message could use a little more work but I wanted to keep the patch as small as possible. Best regards Herbert
Subject: extjs_exception.patch
diff -Naur ./lib/CatalystX/Controller/ExtJS/Direct/API.pm ../CatalystX-ExtJS-1.120000-modified/lib/CatalystX/Controller/ExtJS/Direct/API.pm --- ./lib/CatalystX/Controller/ExtJS/Direct/API.pm 2010-08-17 12:57:25.000000000 +0200 +++ ../CatalystX-ExtJS-1.120000-modified/lib/CatalystX/Controller/ExtJS/Direct/API.pm 2010-08-24 12:56:56.571772151 +0200 @@ -148,6 +148,8 @@ eval { $c->visit($route->build_url( $req->{data} )); my $response = $c->res; + my $status = $response->status; + die "Status $status:\n" if $status >= 400; if ( $response->content_type eq 'application/json' ) { (my $res_body = $response->body) =~ s/^\xEF\xBB\xBF//; # remove BOM my $json = JSON::Any->new->decode( $res_body ); diff -Naur ./t/direct/router/rest_extjs.t ../CatalystX-ExtJS-1.120000-modified/t/direct/router/rest_extjs.t --- ./t/direct/router/rest_extjs.t 2010-08-17 12:57:25.000000000 +0200 +++ ../CatalystX-ExtJS-1.120000-modified/t/direct/router/rest_extjs.t 2010-08-24 11:50:29.366989791 +0200 @@ -40,6 +40,20 @@ POST $api->{url}, Content_Type => 'application/json', Content => q( + {"action":"User","method":"destroy","data":[{"rows":"4"}],"type":"rpc","tid":3} + ), + ), + 'delete non-existing user: request succeeds' +); +$mech->content_contains('exception', '... but response contains exception'); + +count_users(3); + +ok( + $mech->request( + POST $api->{url}, + Content_Type => 'application/json', + Content => q( {"action":"User","method":"destroy","data":[{"rows":"1"}],"type":"rpc","tid":3} ) ),
Hi, this has been fixed in the git repo (https://github.com/monken/catalystx-extjs) and will be released soon. Please check it out and reopen the ticket if you have any objections. From the changes: - catch exceptions in Controller::REST and send a 400 bad_request status to the browser including a message and success: false - Ext.Direct will send an exception if the response status of the subrequest is >= 400 The response includes the status of the subrequest as well as $c->error or the body - status_not_found also includes success => 0 in it's response Am Di 24. Aug 2010, 07:45:15, hl42 schrieb: Show quoted text
> Hi, > > CRUD errors in C::C..ExtJS::REST ('Object could not be found' etc) > set the HTTP status code via $self->status_not_found. > > In C::C::ExtJS::Direct::API the status code is ignored and the error > is returned as a plain message in the JSON response with status 200. > > Unfortunately ExtJS sees this as a success. No error is reported and the > store and the database get out of sync. > > There are two possibilities to fix this: > > 1. return {'success': false} for each failed request > 2. return an exception for each failed request > > I choose alternative 2 for the patch because it's easier (just two > additional lines). The error message could use a little more work but I > wanted to keep the patch as small as possible. > > Best regards > Herbert >