mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-14 16:35:01 -05:00
fix(external-triggers): not passing payload through + incorrect server-side resolver logic (#1801)
* fix integration triggers * ignore text readonly subblocks * fix * fix to ignore readOnly vals * fix var references * simplify * cleanup code
This commit is contained in:
committed by
GitHub
parent
d1fcade5ab
commit
0363f8a33d
@@ -12,53 +12,6 @@ import { WorkflowResolver } from './resolvers/workflow'
|
||||
|
||||
const logger = createLogger('VariableResolver')
|
||||
|
||||
const INVALID_REFERENCE_CHARS = /[+*/=<>!]/
|
||||
|
||||
function isLikelyReferenceSegment(segment: string): boolean {
|
||||
if (!segment.startsWith(REFERENCE.START) || !segment.endsWith(REFERENCE.END)) {
|
||||
return false
|
||||
}
|
||||
|
||||
const inner = segment.slice(1, -1)
|
||||
|
||||
// Starts with space - not a reference
|
||||
if (inner.startsWith(' ')) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Contains only comparison operators or has operators with spaces
|
||||
if (inner.match(/^\s*[<>=!]+\s*$/) || inner.match(/\s[<>=!]+\s/)) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Starts with comparison operator followed by space
|
||||
if (inner.match(/^[<>=!]+\s/)) {
|
||||
return false
|
||||
}
|
||||
|
||||
// For dotted references (like <block.field>)
|
||||
if (inner.includes('.')) {
|
||||
const dotIndex = inner.indexOf('.')
|
||||
const beforeDot = inner.substring(0, dotIndex)
|
||||
const afterDot = inner.substring(dotIndex + 1)
|
||||
|
||||
// No spaces after dot
|
||||
if (afterDot.includes(' ')) {
|
||||
return false
|
||||
}
|
||||
|
||||
// No invalid chars in either part
|
||||
if (INVALID_REFERENCE_CHARS.test(beforeDot) || INVALID_REFERENCE_CHARS.test(afterDot)) {
|
||||
return false
|
||||
}
|
||||
} else if (INVALID_REFERENCE_CHARS.test(inner) || inner.match(/^\d/) || inner.match(/\s\d/)) {
|
||||
// No invalid chars, doesn't start with digit, no space before digit
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
export class VariableResolver {
|
||||
private resolvers: Resolver[]
|
||||
private blockResolver: BlockResolver
|
||||
@@ -197,10 +150,6 @@ export class VariableResolver {
|
||||
result = result.replace(referenceRegex, (match) => {
|
||||
if (replacementError) return match
|
||||
|
||||
if (!isLikelyReferenceSegment(match)) {
|
||||
return match
|
||||
}
|
||||
|
||||
try {
|
||||
const resolved = this.resolveReference(match, resolutionContext)
|
||||
if (resolved === undefined) {
|
||||
@@ -260,10 +209,6 @@ export class VariableResolver {
|
||||
result = result.replace(referenceRegex, (match) => {
|
||||
if (replacementError) return match
|
||||
|
||||
if (!isLikelyReferenceSegment(match)) {
|
||||
return match
|
||||
}
|
||||
|
||||
try {
|
||||
const resolved = this.resolveReference(match, resolutionContext)
|
||||
if (resolved === undefined) {
|
||||
|
||||
@@ -46,8 +46,8 @@ export class BlockResolver implements Resolver {
|
||||
|
||||
const blockId = this.findBlockIdByName(blockName)
|
||||
if (!blockId) {
|
||||
logger.error('Block not found by name', { blockName, reference })
|
||||
throw new Error(`Block "${blockName}" not found`)
|
||||
logger.debug('Block not found by name, skipping resolution', { blockName, reference })
|
||||
return undefined
|
||||
}
|
||||
|
||||
const output = this.getBlockOutput(blockId, context)
|
||||
|
||||
Reference in New Issue
Block a user