Skip to content

fix: [SD_CFX_002] Add isNotPresent/isPresent suffix unary operators to LiquidJS computation engine - #48

Draft
sd-gh-bot wants to merge 1 commit into
masterfrom
fix/sd-cfx-002-isnot-present-operator
Draft

fix: [SD_CFX_002] Add isNotPresent/isPresent suffix unary operators to LiquidJS computation engine#48
sd-gh-bot wants to merge 1 commit into
masterfrom
fix/sd-cfx-002-isnot-present-operator

Conversation

@sd-gh-bot

@sd-gh-bot sd-gh-bot commented Jun 29, 2026

Copy link
Copy Markdown

User description

Problem

Contract generation fails with SD_CFX_002 when Electricity Risk Type = Common Area is selected in the Retrofit flow (e.g. Metergy Solutions, Workspace 353009, Contract SD-3014).

Root cause

Template common_cf_text uses {% if sd_thermal_risk_type isNotPresent %} inside a Liquid computation block. The isNotPresent and isPresent operators are registered in docx-templater/expressions.js (Angular Expressions) but were not recognised by the LiquidJS computation engine (@spotdraft/liquidjs). When the enclosing {% if ... == "Common Area" %} guard evaluated to TRUE, execution reached the unrecognised operator, throwing:

RenderError: cannot eval 'sd_thermal_risk_type isNotPresent' as value, line:53

This bubbled up as ComputationError -> cfexporter HTTP 400 -> SD_CFX_002.

Fix

Add isNotPresent and isPresent as suffix unary operators to src/syntax.js evalExp and validateExpression. Semantics match docx-templater/expressions.js. 10 new tests added; 23 pre-existing failures unchanged.

Immediate mitigation (before deploy)

Data-fix Django shell script provided in incident report to unblock contract 1683267 (SD-3014) now.


Generated description

Below is a concise technical summary of the changes proposed in this PR:
Add suffix unary handling to the Liquid computation parser so evalExp and validateExpression recognize isNotPresent/isPresent and mirror docx-templater semantics in template text. Add unit coverage under test/syntax.js to assert the new operators respond correctly to null, undefined, false, and string values.

TopicDetails
Liquid operators Add suffix unary handling in syntax.js evalExp and validateExpression so Liquid computations support isNotPresent/isPresent matching docx-templater syntax for computation templates.
Modified files (1)
  • src/syntax.js
Latest Contributors(2)
UserCommitDate
neo@spotdraft.comfix: [SD_CFX_002] add ...June 29, 2026
shubham@coderbhai.comAdd lexical validation...July 25, 2018
Suffix operator tests Verify suffix unary operator behavior in test/syntax.js for null, undefined, false, empty string, and populated values to ensure the new semantics work during evaluation.
Modified files (1)
  • test/syntax.js
Latest Contributors(2)
UserCommitDate
neo@spotdraft.comfix: [SD_CFX_002] add ...June 29, 2026
shubham@coderbhai.comAdd lexical validation...July 25, 2018
Review this PR on Baz | Customize your next review

…o LiquidJS evalExp

These operators are used in Liquid computation text (common_cf_text) across templates
such as template 27188 (Metergy Solutions, Workspace 353009). They were already
supported in docx-templater/expressions.js (Angular Expressions) but were silently
unsupported in the LiquidJS computation engine, causing:

  RenderError: cannot eval 'sd_thermal_risk_type isNotPresent' as value, line:53

This only manifested at runtime when the guard condition resolving to a code path
containing the isNotPresent expression evaluated to TRUE (e.g. Electricity Risk
Type = Common Area), returning HTTP 400 from cfexporter and SD_CFX_002 to the UI.

Changes:
- evalExp: detect suffix unary operators before falling through to evalValue
- validateExpression: same — prevents false validation failures
- SUFFIX_UNARY_OPERATORS map: semantics aligned with docx-templater isPresent/isNotPresent
  (null | undefined | false → not present; anything else → present)
- test/syntax.js: 10 new tests covering null, undefined, false, string, empty-string cases

Fixes: SD_CFX_002 generation failure for contracts with Electricity Risk Type = Common Area

Co-authored-by: Anjali Swami <vend-anjaliswami@spotdraft.com>
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.

1 participant