You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Justin Edelson <ju...@gmail.com> on 2010/03/31 01:34:49 UTC

Re: SlingPostServlet saves operations that throw an error in the log but return 200 responses

Michael-
A description of this failure should have been contained in the HTML
response to your POST. The status code is not particularly
informative; you must parse the (X)HTML returned by the Post Servlet.
This is by design.

Justin

On Mar 30, 2010, at 5:31 PM, Michael Yin <yi...@gmail.com> wrote:

> I'm on a fairly recent trunk build, and when I do save operations
> with the
> sling post servlet, I'm  getting OK responses back from the servlet
> but I
> see errors in the sling log, and trying to retrieve the node again
> shows
> that the changes did not happen.
>
> Here is one of the stack traces in the log
>
> org.apache.sling.servlets.post.impl.operations.ModifyOperation
> Exception
> during response processing.
> javax.jcr.nodetype.ConstraintViolationException:
> Unable to perform operation. Node is protected.
> at
> org.apache.jackrabbit.core.ItemValidator.checkCondition
> (ItemValidator.java:303)
> at
> org.apache.jackrabbit.core.ItemValidator.checkModify
> (ItemValidator.java:277)
> at
> org.apache.jackrabbit.core.PropertyImpl.checkSetValue
> (PropertyImpl.java:235)
> at org.apache.jackrabbit.core.PropertyImpl.setValue
> (PropertyImpl.java:690)
> at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:2418)
> at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:1560)
> at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:2139)
> at
> org.apache.sling.servlets.post.impl.helper.SlingPropertyValueHandler.setPropertyAsIs(
> SlingPropertyValueHandler.java:278)
> at
> org.apache.sling.servlets.post.impl.helper.SlingPropertyValueHandler.setProperty(
> SlingPropertyValueHandler.java:106)
> at
> org.apache.sling.servlets.post.impl.operations.ModifyOperation.writeContent(
> ModifyOperation.java:432)
> at
> org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun
> (ModifyOperation.java:100)
> at
> org.apache.sling.servlets.post.AbstractSlingPostOperation.run
> (AbstractSlingPostOperation.java:87)
> at
> org.apache.sling.servlets.post.impl.SlingPostServlet.doPost
> (SlingPostServlet.java:178)
>
>
> -mike

Re: SlingPostServlet saves operations that throw an error in the log but return 200 responses

Posted by Michael Yin <yi...@gmail.com>.
Created https://issues.apache.org/jira/browse/SLING-1483 .

Thanks
<https://issues.apache.org/jira/browse/SLING-1483>-mike

On Thu, Apr 1, 2010 at 3:56 PM, Alexander Klimetschek <ak...@day.com>wrote:

> On Thu, Apr 1, 2010 at 20:13, Michael Yin <yi...@gmail.com> wrote:
> > Just tested this. setting ":status" to "standard" still resulted in a 200
> OK
> > response.
>
> Looks like a bug. I quickly looked at the newest version of the code
> involved and it looks a bit different than before and too complicated
> (*) to see the code paths without debugging. But it seems that it
> could spit out a 200 even if an exception happened.
>
> I think you should report an issue in Jira.
>
> (*) My observations: HtmlResponse and the new JSONResponse have
> prepare() (sets status code before send() sets it again), a
> PN_STATUS_CODE property (never set?), getError() (overrides
> PN_STATUS_CODE?) and a setStatus parameter in send (ignored in
> JSONResponse).
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>

Re: SlingPostServlet saves operations that throw an error in the log but return 200 responses

Posted by Alexander Klimetschek <ak...@day.com>.
On Thu, Apr 1, 2010 at 20:13, Michael Yin <yi...@gmail.com> wrote:
> Just tested this. setting ":status" to "standard" still resulted in a 200 OK
> response.

Looks like a bug. I quickly looked at the newest version of the code
involved and it looks a bit different than before and too complicated
(*) to see the code paths without debugging. But it seems that it
could spit out a 200 even if an exception happened.

I think you should report an issue in Jira.

(*) My observations: HtmlResponse and the new JSONResponse have
prepare() (sets status code before send() sets it again), a
PN_STATUS_CODE property (never set?), getError() (overrides
PN_STATUS_CODE?) and a setStatus parameter in send (ignored in
JSONResponse).

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: SlingPostServlet saves operations that throw an error in the log but return 200 responses

Posted by Michael Yin <yi...@gmail.com>.
Just tested this. setting ":status" to "standard" still resulted in a 200 OK
response.

-mike

On Wed, Mar 31, 2010 at 9:01 AM, Michael Yin <yi...@gmail.com> wrote:

> I will try setting :status to "standard" and see what happens. However,
> currently I have not set it at all.
>
> -mike
>
>
> On Wed, Mar 31, 2010 at 4:46 AM, Alexander Klimetschek <ak...@day.com>wrote:
>
>> On Wed, Mar 31, 2010 at 03:06, Michael Yin <yi...@gmail.com> wrote:
>> > I would argue that errors should be given an appropriate response. Most
>> of
>> > the other actions that I've seen return appropriate error responses,
>> such as
>> > doing xpath searches with improper syntax returns a 500 or when a
>> resource
>> > isn't found, returning a 404. You can still output HTML with a non-200
>> > response. Otherwise it just seems inconsistent.
>>
>> By default, http error codes should be set. This behavior can be
>> controlled via the ":status" parameter.
>>
>>
>> http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html#ManipulatingContent-TheSlingPostServlet%2528servlets.post%2529-%257B%257B%253Astatus%257D%257D
>>
>> The reason for having 200's in some cases is when using ajax/iframe
>> requests from browsers, where non-200 responses might get lost.
>>
>> Regards,
>> Alex
>>
>> --
>> Alexander Klimetschek
>> alexander.klimetschek@day.com
>>
>
>

Re: SlingPostServlet saves operations that throw an error in the log but return 200 responses

Posted by Michael Yin <yi...@gmail.com>.
I will try setting :status to "standard" and see what happens. However,
currently I have not set it at all.

-mike

On Wed, Mar 31, 2010 at 4:46 AM, Alexander Klimetschek <ak...@day.com>wrote:

> On Wed, Mar 31, 2010 at 03:06, Michael Yin <yi...@gmail.com> wrote:
> > I would argue that errors should be given an appropriate response. Most
> of
> > the other actions that I've seen return appropriate error responses, such
> as
> > doing xpath searches with improper syntax returns a 500 or when a
> resource
> > isn't found, returning a 404. You can still output HTML with a non-200
> > response. Otherwise it just seems inconsistent.
>
> By default, http error codes should be set. This behavior can be
> controlled via the ":status" parameter.
>
>
> http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html#ManipulatingContent-TheSlingPostServlet%2528servlets.post%2529-%257B%257B%253Astatus%257D%257D
>
> The reason for having 200's in some cases is when using ajax/iframe
> requests from browsers, where non-200 responses might get lost.
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>

Re: SlingPostServlet saves operations that throw an error in the log but return 200 responses

Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, Mar 31, 2010 at 03:06, Michael Yin <yi...@gmail.com> wrote:
> I would argue that errors should be given an appropriate response. Most of
> the other actions that I've seen return appropriate error responses, such as
> doing xpath searches with improper syntax returns a 500 or when a resource
> isn't found, returning a 404. You can still output HTML with a non-200
> response. Otherwise it just seems inconsistent.

By default, http error codes should be set. This behavior can be
controlled via the ":status" parameter.

http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html#ManipulatingContent-TheSlingPostServlet%2528servlets.post%2529-%257B%257B%253Astatus%257D%257D

The reason for having 200's in some cases is when using ajax/iframe
requests from browsers, where non-200 responses might get lost.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

RE: SlingPostServlet saves operations that throw an error in the log but return 200 responses

Posted by Clemens Wyss <cl...@mysign.ch>.
in the sense of REST I would support mike's objection. But maybe the "by design"-explanantion can make me/us rethink...?

> -----Original Message-----
> From: Michael Yin [mailto:yincrash@gmail.com]
> Sent: Wednesday, March 31, 2010 3:07 AM
> To: users@sling.apache.org
> Subject: Re: SlingPostServlet saves operations that throw an error in
> the log but return 200 responses
>
>
> I would argue that errors should be given an appropriate
> response. Most of
> the other actions that I've seen return appropriate error
> responses, such as
> doing xpath searches with improper syntax returns a 500 or
> when a resource
> isn't found, returning a 404. You can still output HTML with a non-200
> response. Otherwise it just seems inconsistent.
>
> -mike
>
> On Tue, Mar 30, 2010 at 7:34 PM, Justin Edelson
> <ju...@gmail.com>wrote:
>
> > Michael-
> > A description of this failure should have been contained in the HTML
> > response to your POST. The status code is not particularly
> > informative; you must parse the (X)HTML returned by the
> Post Servlet.
> > This is by design.
> >
> > Justin
> >
> > On Mar 30, 2010, at 5:31 PM, Michael Yin <yi...@gmail.com> wrote:
> >
> > > I'm on a fairly recent trunk build, and when I do save operations
> > > with the
> > > sling post servlet, I'm  getting OK responses back from
> the servlet
> > > but I
> > > see errors in the sling log, and trying to retrieve the node again
> > > shows
> > > that the changes did not happen.
> > >
> > > Here is one of the stack traces in the log
> > >
> > > org.apache.sling.servlets.post.impl.operations.ModifyOperation
> > > Exception
> > > during response processing.
> > > javax.jcr.nodetype.ConstraintViolationException:
> > > Unable to perform operation. Node is protected.
> > > at
> > > org.apache.jackrabbit.core.ItemValidator.checkCondition
> > > (ItemValidator.java:303)
> > > at
> > > org.apache.jackrabbit.core.ItemValidator.checkModify
> > > (ItemValidator.java:277)
> > > at
> > > org.apache.jackrabbit.core.PropertyImpl.checkSetValue
> > > (PropertyImpl.java:235)
> > > at org.apache.jackrabbit.core.PropertyImpl.setValue
> > > (PropertyImpl.java:690)
> > > at
> org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:2418)
> > > at
> org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:1560)
> > > at
> org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:2139)
> > > at
> > >
> >
> org.apache.sling.servlets.post.impl.helper.SlingPropertyValueH
> andler.setPropertyAsIs(
> > > SlingPropertyValueHandler.java:278)
> > > at
> > >
> >
> org.apache.sling.servlets.post.impl.helper.SlingPropertyValueH
> andler.setProperty(
> > > SlingPropertyValueHandler.java:106)
> > > at
> > >
> >
> org.apache.sling.servlets.post.impl.operations.ModifyOperation
> .writeContent(
> > > ModifyOperation.java:432)
> > > at
> > >
> org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun
> > > (ModifyOperation.java:100)
> > > at
> > > org.apache.sling.servlets.post.AbstractSlingPostOperation.run
> > > (AbstractSlingPostOperation.java:87)
> > > at
> > > org.apache.sling.servlets.post.impl.SlingPostServlet.doPost
> > > (SlingPostServlet.java:178)
> > >
> > >
> > > -mike
> >
>

Re: SlingPostServlet saves operations that throw an error in the log but return 200 responses

Posted by Michael Yin <yi...@gmail.com>.
I would argue that errors should be given an appropriate response. Most of
the other actions that I've seen return appropriate error responses, such as
doing xpath searches with improper syntax returns a 500 or when a resource
isn't found, returning a 404. You can still output HTML with a non-200
response. Otherwise it just seems inconsistent.

-mike

On Tue, Mar 30, 2010 at 7:34 PM, Justin Edelson <ju...@gmail.com>wrote:

> Michael-
> A description of this failure should have been contained in the HTML
> response to your POST. The status code is not particularly
> informative; you must parse the (X)HTML returned by the Post Servlet.
> This is by design.
>
> Justin
>
> On Mar 30, 2010, at 5:31 PM, Michael Yin <yi...@gmail.com> wrote:
>
> > I'm on a fairly recent trunk build, and when I do save operations
> > with the
> > sling post servlet, I'm  getting OK responses back from the servlet
> > but I
> > see errors in the sling log, and trying to retrieve the node again
> > shows
> > that the changes did not happen.
> >
> > Here is one of the stack traces in the log
> >
> > org.apache.sling.servlets.post.impl.operations.ModifyOperation
> > Exception
> > during response processing.
> > javax.jcr.nodetype.ConstraintViolationException:
> > Unable to perform operation. Node is protected.
> > at
> > org.apache.jackrabbit.core.ItemValidator.checkCondition
> > (ItemValidator.java:303)
> > at
> > org.apache.jackrabbit.core.ItemValidator.checkModify
> > (ItemValidator.java:277)
> > at
> > org.apache.jackrabbit.core.PropertyImpl.checkSetValue
> > (PropertyImpl.java:235)
> > at org.apache.jackrabbit.core.PropertyImpl.setValue
> > (PropertyImpl.java:690)
> > at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:2418)
> > at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:1560)
> > at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:2139)
> > at
> >
> org.apache.sling.servlets.post.impl.helper.SlingPropertyValueHandler.setPropertyAsIs(
> > SlingPropertyValueHandler.java:278)
> > at
> >
> org.apache.sling.servlets.post.impl.helper.SlingPropertyValueHandler.setProperty(
> > SlingPropertyValueHandler.java:106)
> > at
> >
> org.apache.sling.servlets.post.impl.operations.ModifyOperation.writeContent(
> > ModifyOperation.java:432)
> > at
> > org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun
> > (ModifyOperation.java:100)
> > at
> > org.apache.sling.servlets.post.AbstractSlingPostOperation.run
> > (AbstractSlingPostOperation.java:87)
> > at
> > org.apache.sling.servlets.post.impl.SlingPostServlet.doPost
> > (SlingPostServlet.java:178)
> >
> >
> > -mike
>