tracker issue : CF-4197166

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

REST restPath attribute not supporting regex that defines restpath argument as optional

| View in Tracker

Status/Resolution/Reason: Closed/Duplicate/Duplicate

Reporter/Name(from Bugbase): Mosh Teitelbaum / Mosh Teitelbaum (Mosh Teitelbaum)

Created: 10/31/2016

Components: REST Services

Versions: 2016

Failure Type:

Found In Build/Fixed In Build: CF2016_Update3 /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Windows 10 64 bit

Vote Count: 0

Problem Description:
Following up on Bug 4197164, in order to support CORS preflight requests, every endpoint in the API must define an OPTIONS handler.  Some endpoints can include optional path parameters such as "/users" and "/users/123".  ColdFusion's REST support includes the ability to use regular expressions in restPath definitions which should be able to handle this and, so as not to have to create separate OPTIONS handlers for both of these formats, I tried to do just that.  Unfortunately, it is not working as expected.


Steps to Reproduce:
1) Create an endpoint such as:

<cfcomponent rest="true" restpath="/users" produces="application/json">
	<cffunction name="corsPreflight" access="remote" returntype="void" httpMethod="OPTIONS" restPath="{id:.*}">
		<cfargument name="id" type="string" required="false" restargsource="Path" />

		<!--- Do CORS stuff here --->
	</cffunction>
</cfcomponent>

2) Send an OPTIONS request to this endpoint such as "/accounts/123".  This will succeed.
3) Send an OPTIONS request to this endpoint such as "/accounts".  This should succeed but will fail.


Actual Result:

Expected Result:

Any Workarounds:
Create two separate OPTIONS handler functions, one accepting the rest path parameter and one not such as:
	<cffunction name="corsPreflight" access="remote" returntype="void" httpMethod="OPTIONS">
	</cffunction>

	<cffunction name="corsPreflightWithId" access="remote" returntype="void" httpMethod="OPTIONS" restPath="{id:.*}">
	</cffunction>

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

Watson Bug ID:	4197166

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

ColdFusion 2016 Enterprise

Windows Server 2012

Attachments:

Comments:

Hi Adobe, This ticket's status/reason is: Closed/Duplicate. But there is no duplicate ID. What is the duplicate ID? Thanks!, -Aaron
Comment by Aaron N.
1561 | July 10, 2017 12:32:32 AM GMT
Hi Aaron, Duplicate bug [CF-4197195|https://tracker.adobe.com/#/view/CF-4197195]
Comment by HariKrishna K.
1562 | July 10, 2017 05:21:32 AM GMT
HariKrishna, Please reopen this bug. This is not a duplicate of CF-4197195. CF-4197195 is a problem with the order of different endpoint handling methods. This bug, CF-4197166, is a problem with CF's (or Jersey's) regex support in endpoint handler methods. The examples I gave for the two bugs were similar, but the two bugs are very different. Thanks, Mosh
Comment by Mosh T.
1563 | July 10, 2017 06:36:20 AM GMT
HariKrishna, As per the 7/10 comment, can you please reopen this bug?
Comment by Mosh T.
1564 | September 14, 2017 04:20:19 PM GMT