tracker issue : CF-3710341

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

struct.find() (and structFind()) error on missing key

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/AsDesigned

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 02/19/2014

Components: Language

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: PublicBeta /

Priority/Frequency: Major / Some users will encounter

Locale/System: English / Platforms All

Vote Count: 0

Repro:

<cfscript>
// struct.find.cfm
st = {a="b",c="d"};
try {
	result = st.find("e");
}
catch (any e){
	writeDump([e.type,e.message,e.detail]);
}
</cfscript>

This outputs:
array
1	 Expression
2	 Cannot find e key in structure.
3	 The specified key, e, does not exist in the structure.

This should not ERROR if the "e" key is not found, it should just return something to indicate nothing was found. Probably null.

Compare with other find() functions... they just return a "it wasn't found" result.

This bug predates CF11, but as it impacts new functionality in the .find() method, I thought it was relevant to raise it now, during CF11 dev.

-- 
Adam

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

Watson Bug ID:	3710341

External Customer Info:
External Company:  
External Customer Name: Adam Cameron.
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

strcut.find is implemented on top of StructFind functionality and its throw error for ages. Agreed that the structFind behavior is not completely correct but its not possible to correct now as it might cause major backward compatibility issue.
Comment by Awdhesh K.
13445 | February 26, 2014 05:38:00 AM GMT
Changing the behavior of structFind() when the key is not present from exception to a null value will break backward compatibility. Existing applications might have coded to depend on such exception scenario.
Comment by Vijay M.
29925 | September 18, 2018 09:45:58 AM GMT