Skip to content

Commit d50db1d

Browse files
author
Vikhyath Mondreti
committed
add dot check
1 parent b3960ad commit d50db1d

File tree

1 file changed

+16
-3
lines changed
  • apps/sim/app/api/function/execute

1 file changed

+16
-3
lines changed

apps/sim/app/api/function/execute/route.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ function resolveCodeVariables(
3939
resolvedCode = resolvedCode.replace(new RegExp(escapeRegExp(match), 'g'), safeVarName)
4040
}
4141

42-
// Resolve tags with <tag_name> syntax
43-
const tagMatches = resolvedCode.match(/<([a-zA-Z_][a-zA-Z0-9_]*)>/g) || []
42+
// Resolve tags with <tag_name> syntax (including nested paths like <block.response.data>)
43+
const tagMatches = resolvedCode.match(/<([a-zA-Z_][a-zA-Z0-9_.]*[a-zA-Z0-9_])>/g) || []
4444
for (const match of tagMatches) {
4545
const tagName = match.slice(1, -1).trim()
46-
const tagValue = params[tagName] || ''
46+
47+
// Handle nested paths like "getrecord.response.data"
48+
const tagValue = getNestedValue(params, tagName) || ''
4749

4850
// Instead of injecting large JSON directly, create a variable reference
4951
const safeVarName = `__tag_${tagName.replace(/[^a-zA-Z0-9_]/g, '_')}`
@@ -56,6 +58,17 @@ function resolveCodeVariables(
5658
return { resolvedCode, contextVariables }
5759
}
5860

61+
/**
62+
* Get nested value from object using dot notation path
63+
*/
64+
function getNestedValue(obj: any, path: string): any {
65+
if (!obj || !path) return undefined
66+
67+
return path.split('.').reduce((current, key) => {
68+
return current && typeof current === 'object' ? current[key] : undefined
69+
}, obj)
70+
}
71+
5972
/**
6073
* Escape special regex characters in a string
6174
*/

0 commit comments

Comments
 (0)