ColdFusion 10.0  -  Bug 3506757

Created on Tuesday, February 26, 2013

Login for more options

Title

Exceptions in REST Services doesn't trigger Application.cfc's onError or Site-wide Error Handler

Description

Problem Description:
When exceptions occur in ColdFusion 10's new REST Services, the standard exception handling mechanisms don't work.

Steps to Reproduce:
Throw an excaption in CF 10's REST end point.

Actual Result:
Application.cfc's onError and Site-wide Error Handler don't get triggered.

Expected Result:
Application.cfc's onError gets called.

Any Workarounds:
Only time wasting painful workarounds. Some solutions proposed here, but not ideal:

http://stackoverflow.com/q/15015308/188740

Test Configuration

My Hardware and Environment details:

Windows 2008 / Windows 7
ColdFusion 10

App Language(s) English
OS Language(s) English
Platform(s) Win 2008 Server R2 64 bit
Browser(s) Browsers All

Notes (21)

  • Aaron Neff

    3:41:03 AM GMT+00:00 Dec 11, 2014

    Hi Hari,

    Thank you very much for confirming and for determining the specific issue! I've filed that specific scenario as #3866282.

    Thanks!,
    -Aaron

  • Hari Krishna Kallae

    1:55:59 AM GMT+00:00 Dec 9, 2014

    Hi Aaron,
    Verified the test case that you have provided, Site-wide error handler works when there is an "Accept" header of type "text/html" and the REST service should have attribute produces="text/html".

    Here is the modified test case:
    Applicaiton.cfm
    -------------------------------------------
    component {
    THIS.name = "ticket_3506757";
    THIS.applicationTimeout = createTimeSpan(0,0,0,30);
    function onApplicationStart() {
    restInitApplication(expandPath("./"), "foo");
    }
    }

    test.cfc
    ----------------------------------------------------------------
    component restpath="a" {
    remote string function abc() httpmethod="GET" produces="text/html" {
    foo=bar;
    return "b";
    }
    }

    test.cfm
    ------------------------------------------------------------
    <cfhttp url="http://localhost:8500/rest/foo/a">
    <cfhttpparam type="header" name="Accept" value="text/html">
    <cfhttpparam type="Header" name="Accept-Encoding" value="deflate;q=0">
    <cfhttpparam type="Header" name="TE" value="deflate;q=0">
    </cfhttp>
    <cfdump var="#CFHTTP#">

    So, Site-wide error handler, should have worked when "Accept" header is specified with cfhttp, which is currently not happening.
    Currently it works, if both cfhttp has an "Accept" header of type "text/html" and REST service has produces property to "text/html", which should have worked even w/o specifying produces.
    Can you log a separate bug for this specific scenario?

  • Aaron Neff

    11:55:44 PM GMT+00:00 Dec 7, 2014

    I should note: Site-wide error handler is returned when I replace index.cfm's contents w/ <cfset foo = bar> and I request index.cfm, but it is still not returned for the REST requests w/ Content-Type=text/html.

    Thanks!,
    -Aaron

  • Aaron Neff

    11:52:53 PM GMT+00:00 Dec 7, 2014

    Hi Hari and Paul,

    I still see this not fixed. For Content-Type=text/html, REST is returning error responses as "Internal Server Error" (instead of triggering site-wide error handler, and returning its HTML) in CFHTTP.FileContent. Repro:

    CF: CF11 Update 3 (11,0,03,292480) Enterprise Standalone
    OS: x64 Win 2008
    IIS: 7
    Java: 1.7.0_55
    isapi_redirect.dll: v1.2.40.0 Modified Monday, ‎November ‎10, ‎2014, ‏‎5:14:48 PM
    Site-wide Error Handler: /CFIDE/administrator/templates/secure_profile_error.cfm

    Application.cfc
    ---------------
    component {
    THIS.name = "ticket_3506757";
    THIS.applicationTimeout = createTimeSpan(0,0,0,30);
    function onApplicationStart() {
    restInitApplication(expandPath("./"), "foo", {useHOST=true});
    }
    }

    R.cfc
    -----
    component restpath="{a}" {remote string function abc() httpmethod="GET" {foo=bar; return "b";}}

    index.cfm
    ------------
    <cfhttp url="http://www.domain.com/rest/foo/bar">
    <cfhttpparam type="header" name="Accept" value="text/html">
    <cfhttpparam type="Header" name="Accept-Encoding" value="deflate;q=0">
    <cfhttpparam type="Header" name="TE" value="deflate;q=0">
    </cfhttp>
    <cfoutput>#CFHTTP.FileContent#</cfoutput>

    --------------------------------------------
    Request:
    --------------------------------------------
    GET /rest/foo/bar HTTP/1.1
    User-Agent: ColdFusion
    Accept: text/html
    Accept-Encoding: deflate;q=0
    Connection: close
    TE: deflate;q=0
    Host: www.domain.com
    --------------------------------------------
    Response:
    --------------------------------------------
    HTTP/1.1 500 Internal Server Error
    Content-Type: text/html
    Date: Mon, 08 Dec 2014 07:30:21 GMT
    Connection: close
    Content-Length: 21

    Internal Server Error
    --------------------------------------------

    Thanks!,
    -Aaron

  • Hari Krishna Kallae

    4:51:04 AM GMT+00:00 Dec 1, 2014

    Hi Aaron,

    This bug is actually fixed as part of ColdFusion 11 itself.
    And for the second part of the bug(Site wide error handler), you can see Paul's comment below in the comments section, but for convenience, I am adding it here:

    Site wide error handler works with REST services. Whiles invoking a REST service, user can specify the "Accept" Header. If the user specifies the accept header as xml or json, the error is caught and a struct with error code and message is serialized to appropriate format. In this case the site wide error handler is not invoked. It is not good to send the whole HTML content in JSON or XML. But if the requested Content-Type is text/html, then the Site wide handler is invoked and the HTML is returned as the response.

  • Aaron Neff

    3:30:27 AM GMT+00:00 Dec 1, 2014

    Hi Paul,

    Regarding: "Site wide error handler works with REST services."

    I see the site wide error handler is not invoked for REST errors. Repro:

    1) In CF Admin, set "Site-wide Error Handler" to /CFIDE/administrator/templates/secure_profile_error.cfm
    2) Run repro in my previous comment (3:17:52 AM GMT+00:00 Dec 1, 2014)
    3) See site-wide error handler is not displayed

    Since this ticket is for both onError() and site-wide error handler, could you please verify the above?

    Thanks!,
    -Aaron

  • Aaron Neff

    3:17:52 AM GMT+00:00 Dec 1, 2014

    Verified this is fixed in CF11 Update 3 (11,0,03,292245(PreRelease)) using the following repro:

    Application.cfc:
    ----------------------
    component {
    THIS.name = "ticket_3506757";
    function onApplicationStart() {
    restInitApplication(expandPath("./"), "foo", {useHOST=true});
    }
    function onError() {
    if(CGI.SCRIPT_NAME is "/rest") {
    writeLog("in onError()", "error", true, THIS.name);
    }
    }
    }

    index.cfm: empty file

    R.cfc:
    --------
    component restpath="{a}" {remote string function abc() httpmethod="GET" {return [];}}

    1) go to http://www.domain.com/rest/foo/bar
    2) see ticket_3506757.log contains: "Error",[....],"TICKET_3506757","in onError()"

    Thanks!,
    -Aaron

    Adobe, #3506757 should probably be listed in CF11 Update 3's list of fixed tickets.

  • wheatbeat

    8:43:53 AM GMT+00:00 Sep 15, 2014

    Please fix in CF11. Despite claims to the contrary, this has not been fixed.

  • Paul Nibin K J

    12:17:45 AM GMT+00:00 Jul 24, 2014

    Merged the fix in the CF10 hotfix branch.

  • Henry Ho

    1:56:23 PM GMT+00:00 Jul 8, 2014

    Thanks Rupesh, when can we expect the next CF10 update to be available?

  • Rupesh Kumar

    1:00:28 PM GMT+00:00 Jul 8, 2014

    The fix for ColdFusion 10 would go in the next ColdFusion 10 update.

  • JohnnyO5

    7:19:22 AM GMT+00:00 Jun 10, 2014

    But what about ColdFusion 10? This is a major bug in that version.

  • Hari Krishna Kallae

    10:55:32 PM GMT+00:00 Jun 9, 2014

    This is fixed in the latest ColdFusion11 release.

  • JohnnyO5

    9:06:11 PM GMT+00:00 Jun 9, 2014

    I'm surprised it's marked as fixed. In which update was it fixed?

  • Henry Ho

    5:51:25 PM GMT+00:00 Jun 9, 2014

    This is marked as fix, but where is the fix? I'm using CF10 Update 13 and this bug prevents me from writing restful api for production use without proper error handling.

  • Hari Krishna Kallae

    5:49:24 AM GMT+00:00 Dec 18, 2013

    Verified with the latest dev build(#287442), working as expected.

  • Paul Nibin K J

    4:39:42 AM GMT+00:00 Dec 5, 2013

    The Application filter were not running when invoking the webservice method. It was used when we were creating the instance of the service class. So the mappings while executing ting the function. And if the functions threw error, the onError was not called. Moved the application and other required filters while invoking the method.

  • Paul Nibin K J

    9:37:34 AM GMT+00:00 Jun 4, 2013

    Site wide error handler works with REST services. Whiles invoking a REST service, user can specify the "Accept" Header. If the user specifies the accept header as xml or json, the error is caught and a struct with error code and message is serialized to appropriate format. In this case the site wide error handler is not invoked. It is not good to send the whole HTML content in JSON or XML. But if the requested Content-Type is text/html, then the Site wide handler is invoked and the HTML is returned as the response.

    Looking into the onError Application CFC function.

  • JohnnyO5

    10:15:19 AM GMT+00:00 May 6, 2013

    Hi Adobe, it's been a couple months since this has been reported. This is a critical framework bug. Is anyone monitoring this bug forum? Can someone from the ColdFusion team respond?

  • JohnnyO5

    10:05:37 PM GMT+00:00 Apr 6, 2013

    Adobe, can you please respond? We have a large application that we upgraded to CF 10 and we heavily rely on the new REST services, but without error reporting, we're blind to how reliable our app is.

  • JohnnyO5

    8:20:39 AM GMT+00:00 Feb 26, 2013

    Question on how to work around this solution was asked here, but no viable solution was offered.
    http://stackoverflow.com/q/15015308/188740

Duplicate ID
Reported By JohnnyO5

Status

State Closed
Status Fixed
Reason

Importance

Priority 4-Very High
Frequency All users will encounter
Failure Type Non Functioning
Product Area REST Services

Build

Found In Build Final
Fixed In Build CF10_Update14

Attachments (0)

No Files Attached

Votes (5)

  • wheatbeat

    8:40:59 AM GMT+00:00 Sep 15, 2014

    Why still no fix for this? This is a huge issue. And despite claims this was fixed in CF10, it does not appear to be the case. It's still broken in CF11.

  • Adam Cameron

    12:58:07 AM GMT+00:00 Jun 19, 2013

    Should be fixed.

    --
    Adam

  • AlexBaban

    2:32:29 PM GMT+00:00 May 6, 2013

    This is urgent. We're left without proper REST Services exceptions built-in handling.

  • honey-d

    11:44:36 AM GMT+00:00 Apr 1, 2013

    I need to handle errors in a central location when using the REST service. Without onError, I must do something that is not very elegant.

  • Henry Ho

    11:01:27 AM GMT+00:00 Feb 26, 2013

    this is horrible, pls fix

Your session has expired! Click to login
Current form data will be preserved

Cancel