tracker issue : CF-3506757

select a category, or use search below
(searches all categories and all time range)
Title:

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

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Johnny O / Johnny O (Johnny O)

Created: 02/26/2013

Components: REST Services

Versions: 10.0

Failure Type: Non Functioning

Found In Build/Fixed In Build: Final / CF10_Update14

Priority/Frequency: Critical / All users will encounter

Locale/System: English / Win 2008 Server R2 64 bit

Vote Count: 6

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

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3506757

Deployment Phase:	Release Candidate

External Customer Info:
External Company:  
External Customer Name: JohnnyO5
External Customer Email:  
External Test Config: My Hardware and Environment details:



Windows 2008 / Windows 7

ColdFusion 10

Attachments:

Comments:

Question on how to work around this solution was asked here, but no viable solution was offered. http://stackoverflow.com/q/15015308/188740
Comment by External U.
16164 | February 26, 2013 10:50:39 AM GMT
this is horrible, pls fix
Vote by External U.
16185 | February 26, 2013 01:31:27 PM GMT
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.
Vote by External U.
16186 | April 01, 2013 01:14:36 PM GMT
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.
Comment by External U.
16165 | April 06, 2013 11:35:37 PM GMT
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?
Comment by External U.
16166 | May 06, 2013 11:45:19 AM GMT
This is urgent. We're left without proper REST Services exceptions built-in handling.
Vote by External U.
16187 | May 06, 2013 04:02:29 PM GMT
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.
Comment by Paul N.
16167 | June 04, 2013 11:07:34 AM GMT
Should be fixed. -- Adam
Vote by External U.
16188 | June 19, 2013 02:28:07 AM GMT
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.
Comment by Paul N.
16168 | December 05, 2013 07:09:42 AM GMT
Verified with the latest dev build(#287442), working as expected.
Comment by HariKrishna K.
16169 | December 18, 2013 08:19:24 AM GMT
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.
Comment by External U.
16170 | June 09, 2014 07:21:25 PM GMT
I'm surprised it's marked as fixed. In which update was it fixed?
Comment by External U.
16171 | June 09, 2014 10:36:11 PM GMT
This is fixed in the latest ColdFusion11 release.
Comment by HariKrishna K.
16172 | June 10, 2014 12:25:32 AM GMT
But what about ColdFusion 10? This is a major bug in that version.
Comment by External U.
16173 | June 10, 2014 08:49:22 AM GMT
The fix for ColdFusion 10 would go in the next ColdFusion 10 update.
Comment by Rupesh K.
16174 | July 08, 2014 02:30:28 PM GMT
Thanks Rupesh, when can we expect the next CF10 update to be available?
Comment by External U.
16175 | July 08, 2014 03:26:23 PM GMT
Merged the fix in the CF10 hotfix branch.
Comment by Paul N.
16176 | July 24, 2014 01:47:45 AM GMT
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.
Vote by External U.
16189 | September 15, 2014 10:10:59 AM GMT
Please fix in CF11. Despite claims to the contrary, this has not been fixed.
Comment by External U.
16177 | September 15, 2014 10:13:53 AM GMT
Verified this is fixed in CF11 Update 3 (11,0,03,292245(PreRelease)) using the following repro: Application.cfc: ---------------------- component { THIS.name = "ticket_CF-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_CF-3506757.log contains: "Error",[....],"TICKET_CF-3506757","in onError()" Thanks!, -Aaron Adobe, #CF-3506757 should probably be listed in CF11 Update 3's list of fixed tickets.
Comment by External U.
16178 | December 01, 2014 05:47:52 AM GMT
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
Comment by External U.
16179 | December 01, 2014 06:00:27 AM GMT
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.
Comment by HariKrishna K.
16180 | December 01, 2014 07:21:04 AM GMT
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_CF-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
Comment by External U.
16181 | December 08, 2014 02:22:53 AM GMT
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
Comment by External U.
16182 | December 08, 2014 02:25:44 AM GMT
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_CF-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?
Comment by HariKrishna K.
16183 | December 09, 2014 04:25:59 AM GMT
Hi Hari, Thank you very much for confirming and for determining the specific issue! I've filed that specific scenario as #CF-3866282. Thanks!, -Aaron
Comment by External U.
16184 | December 11, 2014 06:11:03 AM GMT