Skip to content

Commit

Permalink
fix(call-service): Don't throw error if mergeContext is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
zachowj committed Jan 2, 2024
1 parent 6c3c22f commit 7388c45
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/nodes/call-service/CallServiceController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ export default class CallServiceController extends InputOutputController<
* @param data - The data to be checked.
* @returns A boolean indicating whether the data is valid or not.
*/
#isValidContextData(
data: unknown
): data is Record<string, string> | undefined {
#isValidContextData(data: unknown): data is Record<string, string> {
return (
typeof data === 'object' &&
!Array.isArray(data) &&
Expand Down Expand Up @@ -178,18 +176,13 @@ export default class CallServiceController extends InputOutputController<
const flowVal = ctx.flow.get(this.node.config.mergeContext);
const globalVal = ctx.global.get(this.node.config.mergeContext);

if (
!this.#isValidContextData(flowVal) ||
!this.#isValidContextData(globalVal)
) {
throw new InputError([
'api-call-service.error.invalid_merge_context',
{
context: this.node.config.mergeContext,
},
]);
if (this.#isValidContextData(flowVal)) {
contextData = flowVal;
}

if (this.#isValidContextData(globalVal)) {
contextData = { ...contextData, ...globalVal };
}
contextData = { ...globalVal, ...flowVal };
}

return { ...configData, ...contextData, ...payload };
Expand Down

0 comments on commit 7388c45

Please sign in to comment.