Skip to content

fix(lineChart): prevent NullPointerException when lines is not configured#4919

Open
Ma77Ball wants to merge 6 commits intoapache:mainfrom
Ma77Ball:fix/GPC_NPE
Open

fix(lineChart): prevent NullPointerException when lines is not configured#4919
Ma77Ball wants to merge 6 commits intoapache:mainfrom
Ma77Ball:fix/GPC_NPE

Conversation

@Ma77Ball
Copy link
Copy Markdown
Contributor

@Ma77Ball Ma77Ball commented May 4, 2026

What changes were proposed in this PR?

LineChartOpDesc declared var lines: util.List[LineConfig] = _, which defaults to null in Scala/Java. Calling generatePythonCode() on a freshly constructed instance immediately crashed with a NullPointerException at
createPlotlyFigure because .asScala.map(...) was called on a null reference.

Two changes:

  • Default lines to new util.ArrayListLineConfig instead of null, so it is always safe to iterate.
  • Add assert(lines.asScala.nonEmpty, "At least one line must be configured") at the top of createPlotlyFigure(), matching the explicit assertion pattern used by sibling visualizers (HeatMapOpDesc, BarChartOpDesc).

Any related issues, documentation, or discussions?

closes: #4811

How was this PR tested?

Unit tests in LineChartOpDescSpec cover:

  • Default-constructed LineChartOpDesc throws AssertionError with a descriptive message when lines is empty
  • Explicitly setting lines to an empty list also throws AssertionError
  • A fully configured operator with at least one LineConfig generates valid Python code containing the expected Plotly structure

Was this PR authored or co-authored using generative AI tooling?

Co-authored with Claude opus 4.6 in compliance with ASF

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Line Chart visualization operator to fail fast when no line series are configured, instead of crashing with a NullPointerException during Python code generation. It fits into the visualization operator code by aligning LineChartOpDesc's configuration handling with the validation style used by similar chart operators.

Changes:

  • Initialize LineChartOpDesc.lines with an empty ArrayList instead of leaving it null.
  • Add a non-empty assertion in createPlotlyFigure() before generating Plotly traces.
  • Update LineChartOpDescSpec to expect AssertionError for default and explicitly empty lines configurations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/lineChart/LineChartOpDesc.scala Changes Line Chart config initialization and adds fail-fast validation before trace generation.
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/lineChart/LineChartOpDescSpec.scala Updates unit tests to cover the new empty/default lines validation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Ma77Ball
Copy link
Copy Markdown
Contributor Author

Ma77Ball commented May 5, 2026

@aglinxinyuan please review.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.12%. Comparing base (9fc5b39) to head (6de4222).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4919      +/-   ##
============================================
- Coverage     42.68%   42.12%   -0.57%     
+ Complexity     2183     2181       -2     
============================================
  Files          1031      980      -51     
  Lines         38110    36254    -1856     
  Branches       4004     3787     -217     
============================================
- Hits          16269    15271     -998     
+ Misses        20824    20051     -773     
+ Partials       1017      932      -85     
Flag Coverage Δ *Carryforward flag
access-control-service 39.53% <ø> (ø)
agent-service 33.72% <ø> (ø) Carriedforward from c533305
amber 43.14% <100.00%> (-0.02%) ⬇️
computing-unit-managing-service 0.00% <ø> (ø)
config-service 0.00% <ø> (ø)
file-service 33.24% <ø> (ø)
frontend 30.53% <ø> (-2.48%) ⬇️ Carriedforward from c533305
python 87.57% <ø> (-1.33%) ⬇️ Carriedforward from c533305
workflow-compiling-service 47.72% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

☔ 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.

@Ma77Ball
Copy link
Copy Markdown
Contributor Author

Ma77Ball commented May 7, 2026

@aglinxinyuan, can you merge if it looks good?

@aglinxinyuan aglinxinyuan enabled auto-merge (squash) May 7, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LineChartOpDesc.generatePythonCode throws NPE when lines is null (the default)

4 participants