fix(lineChart): prevent NullPointerException when lines is not configured#4919
Open
Ma77Ball wants to merge 4 commits intoapache:mainfrom
Open
fix(lineChart): prevent NullPointerException when lines is not configured#4919Ma77Ball wants to merge 4 commits intoapache:mainfrom
Ma77Ball wants to merge 4 commits intoapache:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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.lineswith an emptyArrayListinstead of leaving itnull. - Add a non-empty assertion in
createPlotlyFigure()before generating Plotly traces. - Update
LineChartOpDescSpecto expectAssertionErrorfor default and explicitly emptylinesconfigurations.
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.
Contributor
Author
|
@aglinxinyuan please review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Any related issues, documentation, or discussions?
#4811
How was this PR tested?
Unit tests in LineChartOpDescSpec cover:
Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude opus 4.6 in compliance with ASF