Skip to content

Commit cb2667c

Browse files
committed
fix backwards compat reachability
1 parent 6fac012 commit cb2667c

File tree

1 file changed

+30
-35
lines changed
  • apps/sim/executor/variables/resolvers

1 file changed

+30
-35
lines changed

apps/sim/executor/variables/resolvers/block.ts

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -88,45 +88,40 @@ export class BlockResolver implements Resolver {
8888
blockOutputSchemas,
8989
})!
9090

91-
if (result.value !== undefined) {
92-
return result.value
93-
}
94-
95-
if (output !== undefined && pathParts.length > 0) {
96-
if (
97-
block.metadata?.id === 'response' &&
98-
pathParts[0] === 'response' &&
99-
output?.response === undefined
100-
) {
101-
const adjustedPathParts = pathParts.slice(1)
102-
if (adjustedPathParts.length === 0) {
103-
return output
104-
}
105-
const fallbackResult = navigatePath(output, adjustedPathParts)
106-
if (fallbackResult !== undefined) {
107-
return fallbackResult
91+
return result.value
92+
} catch (error) {
93+
if (error instanceof InvalidFieldError) {
94+
if (output !== undefined && pathParts.length > 0) {
95+
if (
96+
block.metadata?.id === 'response' &&
97+
pathParts[0] === 'response' &&
98+
output?.response === undefined
99+
) {
100+
const adjustedPathParts = pathParts.slice(1)
101+
if (adjustedPathParts.length === 0) {
102+
return output
103+
}
104+
const fallbackResult = navigatePath(output, adjustedPathParts)
105+
if (fallbackResult !== undefined) {
106+
return fallbackResult
107+
}
108108
}
109-
}
110109

111-
const isWorkflowBlock =
112-
block.metadata?.id === 'workflow' || block.metadata?.id === 'workflow_input'
113-
if (
114-
isWorkflowBlock &&
115-
pathParts[0] === 'result' &&
116-
pathParts[1] === 'response' &&
117-
output?.result?.response === undefined
118-
) {
119-
const adjustedPathParts = ['result', ...pathParts.slice(2)]
120-
const fallbackResult = navigatePath(output, adjustedPathParts)
121-
if (fallbackResult !== undefined) {
122-
return fallbackResult
110+
const isWorkflowBlock =
111+
block.metadata?.id === 'workflow' || block.metadata?.id === 'workflow_input'
112+
if (
113+
isWorkflowBlock &&
114+
pathParts[0] === 'result' &&
115+
pathParts[1] === 'response' &&
116+
output?.result?.response === undefined
117+
) {
118+
const adjustedPathParts = ['result', ...pathParts.slice(2)]
119+
const fallbackResult = navigatePath(output, adjustedPathParts)
120+
if (fallbackResult !== undefined) {
121+
return fallbackResult
122+
}
123123
}
124124
}
125-
}
126-
127-
return undefined
128-
} catch (error) {
129-
if (error instanceof InvalidFieldError) {
130125
throw new Error(error.message)
131126
}
132127
throw error

0 commit comments

Comments
 (0)