Skip to content

fix: Chart not displayed when formula references an undefined field#3360

Merged
mtrezza merged 1 commit into
parse-community:alphafrom
mtrezza:fix/undefined-values-in-chat-formula
May 18, 2026
Merged

fix: Chart not displayed when formula references an undefined field#3360
mtrezza merged 1 commit into
parse-community:alphafrom
mtrezza:fix/undefined-values-in-chat-formula

Conversation

@mtrezza
Copy link
Copy Markdown
Member

@mtrezza mtrezza commented May 18, 2026

Pull Request

Issue

In the Data Browser, when creating a chart (e.g. bar chart) and adding a calculated value with the formula operator, the chart did not render any data if the formula referenced a field whose value was undefined (or missing) on the data rows.

This was inconsistent with the sum operator, which already treats a missing/undefined field as 0 and still renders the chart.

Approach

When expr-eval-fork evaluates a formula and encounters an identifier that is not in the variables map, it throws. The error was being caught and evaluateFormula returned null for every row, leaving the chart with no data.

evaluateFormula now fills in any variables referenced by the parsed formula but missing from the variables map with 0 before evaluation. This makes formula behave consistently with sum: a referenced field that is undefined on a row is treated as 0, and the chart renders.

Note that this only affects runtime evaluation. Formula validation in the chart configuration dialog still rejects unknown identifiers, so genuine typos are caught at configuration time.

Tasks

  • Add tests

Summary by CodeRabbit

  • Bug Fixes

    • Formulas now gracefully handle missing variables by defaulting them to 0 instead of producing errors or invalid results.
  • Tests

    • Updated formula evaluation tests to verify undefined variable handling.
    • Added chart rendering tests to ensure visualizations display correctly when referenced fields are undefined.

Review Change Stack

@parse-github-assistant
Copy link
Copy Markdown

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 536b7885-ad5b-4d4e-94e0-a4dc606a8ebf

📥 Commits

Reviewing files that changed from the base of the PR and between 5f0c479 and bc22ca1.

📒 Files selected for processing (3)
  • src/lib/FormulaEvaluator.js
  • src/lib/tests/FormulaEvaluator.test.js
  • src/lib/tests/GraphDataUtils.test.js

📝 Walkthrough

Walkthrough

Formula evaluation now handles missing variables by defaulting them to 0. The evaluateFormula function builds a safe variables object that fills in any referenced-but-undefined variables before passing to the expression evaluator. Tests verify this behavior at both unit and integration levels.

Changes

Formula evaluation with undefined variable handling

Layer / File(s) Summary
FormulaEvaluator implementation and unit tests
src/lib/FormulaEvaluator.js, src/lib/tests/FormulaEvaluator.test.js
evaluateFormula creates a safeVariables object that defaults any expression variables missing from the input variables to 0; unit tests replace the previous undefined-returns-null expectation with tests for arithmetic operations on missing variables.
GraphDataUtils integration tests with formula operator
src/lib/tests/GraphDataUtils.test.js
Two new test cases verify processBarLineData with the formula operator produces non-empty charts when referenced fields are undefined on some or all rows, with computed values treating undefined fields as 0.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Engage In Review Feedback ❓ Inconclusive Cannot verify review feedback engagement. PR is open with single minimal commit. No access to GitHub review interface to confirm feedback existence or responses. Check GitHub PR #3360 reviews/comments directly. Verify commits address feedback or discussions show retraction agreement.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: Chart not displayed when formula references an undefined field' begins with 'fix:' prefix and clearly describes the main issue being fixed—charts not rendering when formulas reference undefined fields.
Description check ✅ Passed The description includes all required sections from the template: Issue (explaining the problem and inconsistency), Approach (detailing the solution), and Tasks (marking tests as added). It provides comprehensive context for the changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Check ✅ Passed No security vulnerabilities found. Code uses expr-eval-fork 3.0.3 (patched), proper input validation, safe regex, correct error handling, and result validation. PR change is secure.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.20.0)

OpenGrep fatal error (exit code 2): [00.15][ERROR]: Error: exception Unix_error: No such file or directory stat src/lib/FormulaEvaluator.js
Raised by primitive operation at UTmp.replace_named_pipe_by_regular_file_if_needed in file "libs/commons/UTmp.ml", line 145, characters 8-27
Called from Scan_CLI.replace_target_roots_by_regular_files_where_needed.(fun) in file "src/osemgrep/cli_scan/Scan_CLI.ml", lines 1086-1087, characters 19-65
Called from List_.fast_map in file "libs/commons/List_.ml", line 81, characters 17-20
Called from


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.

@mtrezza mtrezza merged commit 9666935 into parse-community:alpha May 18, 2026
10 of 11 checks passed
parseplatformorg pushed a commit that referenced this pull request May 18, 2026
## [9.1.2-alpha.1](9.1.1...9.1.2-alpha.1) (2026-05-18)

### Bug Fixes

* Chart not displayed when formula references an undefined field ([#3360](#3360)) ([9666935](9666935))
@parseplatformorg
Copy link
Copy Markdown
Contributor

🎉 This change has been released in version 9.1.2-alpha.1

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label May 18, 2026
@mtrezza mtrezza deleted the fix/undefined-values-in-chat-formula branch May 18, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:released-alpha Released as alpha version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants