Skip to content

send source columns in generic sql op form also#1702

Merged
Ishankoradia merged 1 commit into
mainfrom
generic_sql_bug
Mar 5, 2026
Merged

send source columns in generic sql op form also#1702
Ishankoradia merged 1 commit into
mainfrom
generic_sql_bug

Conversation

@Ishankoradia

@Ishankoradia Ishankoradia commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Fixed source column tracking in SQL operation forms to correctly preserve column selections during creation and editing operations.

@coderabbitai

coderabbitai Bot commented Mar 2, 2026

Copy link
Copy Markdown

Walkthrough

This change adds client-side state management for source columns in the GenericSqlOpForm component. It introduces a srcColumns state variable and a fetchAndSetSourceColumns function to dynamically populate source columns from node data, replacing previously hardcoded empty values in form payloads.

Changes

Cohort / File(s) Summary
Source Column State Management
src/components/TransformWorkflow/FlowEditor/Components/OperationPanel/Forms/GenericSqlOpForm.tsx
Adds new srcColumns state and fetchAndSetSourceColumns function to track source columns from node.data.output_columns; populates source_columns during edit mode by reading from operation_config; replaces hardcoded empty arrays with dynamic state in create and edit payloads; extends component lifecycle to initialize srcColumns for new operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding source columns tracking and submission to the generic SQL operation form, which is the primary focus of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch generic_sql_bug

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/TransformWorkflow/FlowEditor/Components/OperationPanel/Forms/GenericSqlOpForm.tsx (1)

135-142: ⚠️ Potential issue | 🟠 Major

Add action to the useEffect dependency array.

The effect branches on action (line 137) to determine whether to fetch edit config or source columns, but action is missing from the dependencies (line 142). Since OperationForm doesn't remount when action changes via panelOpFormState.current, the effect won't re-run when the mode switches between 'create' and 'edit'/'view'. This causes stale initialization—the form may fetch the wrong data or load with outdated state.

Fix
-  }, [session, node]);
+  }, [session, node, action]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/components/TransformWorkflow/FlowEditor/Components/OperationPanel/Forms/GenericSqlOpForm.tsx`
around lines 135 - 142, The useEffect that decides between
fetchAndSetConfigForEdit() and fetchAndSetSourceColumns() depends on the
variable action but does not include it in the dependency array; update the
dependency array of the useEffect (the effect that checks node?.data.isDummy and
calls fetchAndSetConfigForEdit or fetchAndSetSourceColumns) to include action
alongside session and node so the effect re-runs when action changes and the
form initializes correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/components/TransformWorkflow/FlowEditor/Components/OperationPanel/Forms/GenericSqlOpForm.tsx`:
- Around line 51-55: Guard against undefined source/output columns before
updating state and before sending payloads: in fetchAndSetSourceColumns use
node.data.output_columns ?? [] when calling setSrcColumns so srcColumns is
always a string[]; likewise when destructuring source_columns from
operation_config.config ensure a default (e.g., const { source_columns = [] } =
operation_config.config || {}) so source_columns is never undefined; finally
ensure the payloads built for CreateOperationNodePayload and
EditOperationNodePayload use srcColumns ?? [] (or the guarded source_columns) so
the API always receives a string[].

---

Outside diff comments:
In
`@src/components/TransformWorkflow/FlowEditor/Components/OperationPanel/Forms/GenericSqlOpForm.tsx`:
- Around line 135-142: The useEffect that decides between
fetchAndSetConfigForEdit() and fetchAndSetSourceColumns() depends on the
variable action but does not include it in the dependency array; update the
dependency array of the useEffect (the effect that checks node?.data.isDummy and
calls fetchAndSetConfigForEdit or fetchAndSetSourceColumns) to include action
alongside session and node so the effect re-runs when action changes and the
form initializes correctly.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 86651f0 and aca8c46.

📒 Files selected for processing (1)
  • src/components/TransformWorkflow/FlowEditor/Components/OperationPanel/Forms/GenericSqlOpForm.tsx

Comment on lines +51 to +55
const fetchAndSetSourceColumns = async () => {
if (node) {
setSrcColumns(node.data.output_columns);
}
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# First, find the target file
fd "GenericSqlOpForm.tsx" -HI

# Also search for related type definition files
fd "transform-v2.types.ts" -HI
fd "OperationFormProps" -HI

Repository: DalgoT4D/webapp

Length of output: 187


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Get line count for GenericSqlOpForm.tsx
wc -l src/components/TransformWorkflow/FlowEditor/Components/OperationPanel/Forms/GenericSqlOpForm.tsx

# Read the relevant portions of GenericSqlOpForm.tsx
echo "=== Lines 40-130 of GenericSqlOpForm.tsx ==="
sed -n '40,130p' src/components/TransformWorkflow/FlowEditor/Components/OperationPanel/Forms/GenericSqlOpForm.tsx

echo ""
echo "=== Lines 70-90 of GenericSqlOpForm.tsx ==="
sed -n '70,90p' src/components/TransformWorkflow/FlowEditor/Components/OperationPanel/Forms/GenericSqlOpForm.tsx

Repository: DalgoT4D/webapp

Length of output: 3436


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the types file
wc -l src/types/transform-v2.types.ts

echo "=== Full transform-v2.types.ts ==="
cat -n src/types/transform-v2.types.ts

Repository: DalgoT4D/webapp

Length of output: 4599


🏁 Script executed:

#!/bin/bash
set -eulo pipefail

# Search for GenericDataConfig
rg "GenericDataConfig" -nC 5

# Also check if there are imports in GenericSqlOpForm.tsx
echo "=== Imports and type usage in GenericSqlOpForm.tsx ==="
sed -n '1,40p' src/components/TransformWorkflow/FlowEditor/Components/OperationPanel/Forms/GenericSqlOpForm.tsx

Repository: DalgoT4D/webapp

Length of output: 4314


Guard source_columns and output_columns defaults before setting state.

At line 53, setSrcColumns(node.data.output_columns) doesn't handle cases where output_columns is undefined. Similarly, at line 121, source_columns is destructured from operation_config.config (typed as any), which may not have this field. If either is missing, srcColumns becomes undefined and gets posted to the API at lines 75 and 87, violating the string[] requirement in CreateOperationNodePayload and EditOperationNodePayload.

Proposed fix
-  const fetchAndSetSourceColumns = async () => {
-    if (node) {
-      setSrcColumns(node.data.output_columns);
-    }
-  };
+  const fetchAndSetSourceColumns = () => {
+    setSrcColumns(node?.data?.output_columns ?? []);
+  };

@@
       const { sql_statement_2, sql_statement_1, source_columns }: GenericDataConfig =
         operation_config.config;
-      setSrcColumns(source_columns);
+      setSrcColumns(source_columns ?? []);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/components/TransformWorkflow/FlowEditor/Components/OperationPanel/Forms/GenericSqlOpForm.tsx`
around lines 51 - 55, Guard against undefined source/output columns before
updating state and before sending payloads: in fetchAndSetSourceColumns use
node.data.output_columns ?? [] when calling setSrcColumns so srcColumns is
always a string[]; likewise when destructuring source_columns from
operation_config.config ensure a default (e.g., const { source_columns = [] } =
operation_config.config || {}) so source_columns is never undefined; finally
ensure the payloads built for CreateOperationNodePayload and
EditOperationNodePayload use srcColumns ?? [] (or the guarded source_columns) so
the API always receives a string[].

@sentry

sentry Bot commented Mar 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.36%. Comparing base (86651f0) to head (aca8c46).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1702      +/-   ##
==========================================
+ Coverage   75.34%   75.36%   +0.02%     
==========================================
  Files         107      107              
  Lines        7966     7973       +7     
  Branches     1927     1931       +4     
==========================================
+ Hits         6002     6009       +7     
+ Misses       1927     1840      -87     
- Partials       37      124      +87     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

inputName = 'chained';
}

const fetchAndSetSourceColumns = async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why async ? we are not awaiting it anywhere

@Ishankoradia Ishankoradia Mar 5, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont need to await for an api call always. It can also run asynchronous in a non-blocking way. its like trigger it and forget.

Unless if we had some loading and couldn't move forward without it the results of this api, we would use await.

@himanshudube97

@Ishankoradia Ishankoradia merged commit 7761cf2 into main Mar 5, 2026
6 checks passed
@Ishankoradia Ishankoradia deleted the generic_sql_bug branch March 5, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants