ShawnGarello commented on code in PR #8981:
URL: https://github.com/apache/texera/pull/8981#discussion_r4327891019
##########
agent-service/src/agent/tools/workflow-crud-tools.ts:
##########
@@ -57,6 +57,47 @@ function formatInputArgs(args: Record<string, any>): string {
return `Input: ${JSON.stringify(compact)}`;
}
+/**
+ * Checks every port index and source operator in inputOperatorIds and returns
the links to create,
+ * or the first error. It doesn't change the workflow, so callers must run it
before any mutation.
+ */
+function resolveInputLinks(
+ workflowState: WorkflowState,
+ operatorId: string,
+ inputPorts: PortDescription[],
+ inputOperatorIds: Record<string, string[]> | undefined,
+ inputInfo: string
+): { links: Omit<OperatorLink, "linkID">[] } | { error: string } {
+ const links: Omit<OperatorLink, "linkID">[] = [];
+ for (const [portIndexStr, sourceOpIds] of Object.entries(inputOperatorIds ??
{})) {
+ const targetPortIdx = parseInt(portIndexStr, 10);
+ if (isNaN(targetPortIdx) || targetPortIdx < 0) {
+ return { error: `Invalid input port index: "${portIndexStr}". Must be a
non-negative integer. ${inputInfo}` };
+ }
+ if (targetPortIdx >= inputPorts.length) {
+ return {
+ error: `Input port index ${targetPortIdx} out of range. Operator
"${operatorId}" has ${inputPorts.length} input port(s). ${inputInfo}`,
+ };
+ }
+ const targetPortId = inputPorts[targetPortIdx].portID;
+
+ for (const sourceOpId of sourceOpIds) {
+ const sourceOp = workflowState.getOperator(sourceOpId);
Review Comment:
Applied in bee292e, with a test for each tool. Thanks!
##########
agent-service/src/agent/tools/workflow-crud-tools.ts:
##########
@@ -57,6 +57,47 @@ function formatInputArgs(args: Record<string, any>): string {
return `Input: ${JSON.stringify(compact)}`;
}
+/**
+ * Checks every port index and source operator in inputOperatorIds and returns
the links to create,
+ * or the first error. It doesn't change the workflow, so callers must run it
before any mutation.
+ */
+function resolveInputLinks(
+ workflowState: WorkflowState,
+ operatorId: string,
+ inputPorts: PortDescription[],
+ inputOperatorIds: Record<string, string[]> | undefined,
+ inputInfo: string
+): { links: Omit<OperatorLink, "linkID">[] } | { error: string } {
+ const links: Omit<OperatorLink, "linkID">[] = [];
+ for (const [portIndexStr, sourceOpIds] of Object.entries(inputOperatorIds ??
{})) {
+ const targetPortIdx = parseInt(portIndexStr, 10);
+ if (isNaN(targetPortIdx) || targetPortIdx < 0) {
+ return { error: `Invalid input port index: "${portIndexStr}". Must be a
non-negative integer. ${inputInfo}` };
+ }
Review Comment:
Applied in bee292e, with tests for `"1abc"` and `"1.5"` in both tools.
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]