Skip to content

Fix chart export stripping flow node data (ToolboxFunction, Constant)#3041

Merged
ebrattli merged 2 commits into
mainfrom
fix/chart-flow-node-data-loss
May 29, 2026
Merged

Fix chart export stripping flow node data (ToolboxFunction, Constant)#3041
ebrattli merged 2 commits into
mainfrom
fix/chart-flow-node-data-loss

Conversation

@ebrattli
Copy link
Copy Markdown
Contributor

@ebrattli ebrattli commented May 29, 2026

Bump

  • Patch
  • Minor
  • Major

Changelog

Fixed

  • Fixed chart export/import stripping flow node data (selectedOperation, parameterValues for ToolboxFunction nodes; name, value for Constant nodes), which caused Fusion to crash with TypeError: Cannot read properties of undefined (reading 'op') after a Toolkit round-trip.

Summary

  • ChartResponse.as_request_resource() was calling the base class implementation which used extra="ignore" when validating the response into a request. This silently dropped any field not declared in Toolkit's FlowData Pydantic model — including selectedOperation, parameterValues (for ToolboxFunction nodes) and name, value (for Constant nodes).
  • Fusion reads these fields when rendering charts. After a Toolkit export/import, opening the chart in Fusion caused TypeError: Cannot read properties of undefined (reading 'op') because node.data.selectedOperation was undefined.
  • Fix: override as_request_resource() in ChartResponse to dump only the known response-only fields (created_time, last_updated_time, owner_id) explicitly, then validate with extra="allow" so all nested node data is preserved opaquely.

Test plan

  • test_chart_response_to_request_preserves_flow_node_data — new regression test verifying that Constant (name, value) and ToolboxFunction (selectedOperation, parameterValues) node data survive the response→request conversion, and that response-only fields are excluded
  • All existing TestChartIO tests continue to pass

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 29, 2026

☂️ Code Coverage

current status: ✅

Overall Coverage

Statements Covered Coverage Threshold Status
43159 37086 86% 80% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
cognite_toolkit/_cdf_tk/client/resource_classes/chart.py 95% 🟢
TOTAL 95% 🟢

updated for commit: 86edf65 by action🐍

@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.92%. Comparing base (f2e8cb6) to head (86edf65).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3041   +/-   ##
=======================================
  Coverage   85.92%   85.92%           
=======================================
  Files         470      470           
  Lines       43158    43159    +1     
=======================================
+ Hits        37085    37086    +1     
  Misses       6073     6073           
Files with missing lines Coverage Δ
...e_toolkit/_cdf_tk/client/resource_classes/chart.py 94.59% <100.00%> (-2.63%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ChartResponse.as_request_resource() was validating via the base class
with extra="ignore", which silently dropped all unmodeled fields in
FlowData nodes (selectedOperation, parameterValues, name, value, etc.).
Fusion reads these fields to render calculations, causing a TypeError at
node.data.selectedOperation.op on migrated charts.

Fix: dump only response-only fields explicitly, then validate the result
with extra="allow" to preserve all nested node data opaquely.

## Bump
- [x] Patch
- [ ] Minor
- [ ] Major

## Changelog
### Fixed
- Fixed chart export/import stripping flow node data (`selectedOperation`, `parameterValues` for `ToolboxFunction` nodes; `name`, `value` for `Constant` nodes), which caused Fusion to crash with `TypeError: Cannot read properties of undefined (reading 'op')` after a Toolkit round-trip.
@ebrattli ebrattli force-pushed the fix/chart-flow-node-data-loss branch from 70ef7e4 to 0bd4b01 Compare May 29, 2026 11:34
@ebrattli
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the as_request_resource method in the Chart resource class to serialize the model to JSON while excluding metadata fields (created_time, last_updated_time, and owner_id), and then validate it back into a ChartRequest. This ensures that nested flow node data within the workflow collection is preserved. A unit test has been added to verify this behavior. I have no feedback to provide as there are no review comments.

@ebrattli ebrattli marked this pull request as ready for review May 29, 2026 11:51
@ebrattli ebrattli requested review from a team as code owners May 29, 2026 11:51
@ebrattli ebrattli merged commit 2c1bab9 into main May 29, 2026
14 checks passed
@ebrattli ebrattli deleted the fix/chart-flow-node-data-loss branch May 29, 2026 12:16
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