Handle struct types in item category and modifiers during merge

Claude sometimes returns category or modifiers as objects instead
of strings. Added isSimpleValue checks to prevent cast errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-03-09 21:04:34 -07:00
parent d8a308a03e
commit 9a28091601

View file

@ -401,7 +401,8 @@
</cfif>
<!--- Get item's category --->
<cfset itemCategory = structKeyExists(item, "category") ? trim(item.category) : "">
<cfset itemCatRaw = structKeyExists(item, "category") ? item.category : "">
<cfset itemCategory = isSimpleValue(itemCatRaw) ? trim(itemCatRaw) : "">
<!--- Find category-level modifiers for this category --->
<cfif len(itemCategory)>
@ -412,7 +413,8 @@
<!--- Check if modifier is not already assigned --->
<cfset alreadyAssigned = false>
<cfloop array="#item.modifiers#" index="existingMod">
<cfif lCase(existingMod) EQ lCase(mod.name)>
<cfset existingModName = isSimpleValue(existingMod) ? existingMod : (isStruct(existingMod) AND structKeyExists(existingMod, "name") ? existingMod.name : "")>
<cfif len(existingModName) AND lCase(existingModName) EQ lCase(mod.name)>
<cfset alreadyAssigned = true>
<cfbreak>
</cfif>