Skip to content

Conversation

@takyyon
Copy link
Contributor

@takyyon takyyon commented Jan 24, 2026

Commit Type

  • feature - New functionality
  • fix - Bug fix
  • refactor - Code restructuring without behavior change
  • perf - Performance improvement
  • docs - Documentation update
  • test - Test-related changes
  • chore - Maintenance/tooling

Risk Level

  • Low - Minor changes, limited scope
  • Medium - Moderate changes, some user impact
  • High - Major changes, significant user/system impact

What & Why

Problem

When using dictionary parameters (like SQL's setColumns) with compound token expressions (e.g., @{variables('year')}-@{variables('month')}-@{variables('date')}), the UI serializes the value incorrectly as a JSON string instead of a proper JSON object.

Expected output:

"setColumns": {
  "DATE": "@{variables('year')}-@{variables('month')}-@{variables('date')}"
}

Actual (broken) output:

"setColumns": "{\n \"DATE\" : @{variables('year')}-@{variables('month')}-@{variables('date')}\n}"

The entire dictionary is serialized as a string literal instead of a JSON object, causing runtime failures.

Root Cause

The convertValueType function in keyvalueitem.ts determines whether values should be quoted in JSON. When a value contains tokens (containsTokenSegments returns true), the function returns the original type (e.g., any) instead of string. This causes insertQutationForStringType to not add quotes around compound expressions like @{var1}-@{var2}.

Without quotes, the generated JSON is invalid because compound expressions with embedded tokens cannot be valid JSON values on their own.

Fix Options Analyzed

Option 1: Fix in parameterValueToJSONString (Not chosen)

  • Location: libs/designer/src/lib/core/utils/parameters/helper.ts
  • Approach: Modify the serialization step to detect compound expressions and wrap them in quotes
  • Pros: Single point of fix at serialization layer
  • Cons:
    • The existing logic for adding quotes around tokens is flawed (checks immediate neighbors, not JSON context)
    • Would require significant changes to understand JSON structural context
    • Fixing at serialization means the intermediate representation is still wrong

Option 2: Fix in convertKeyValueItemToSegments / convertValueType (Chosen)

  • Location: libs/designer-ui/src/lib/editor/base/utils/keyvalueitem.ts
  • Approach: When value contains tokens mixed with other content (compound expressions), treat as string type
  • Pros:
    • Fixes at the source where ValueSegments are created
    • Clean separation of concerns - the function that determines type correctly identifies string types
    • Minimal, targeted change (3 lines + comment)
    • Consistent with existing pattern of type conversion
  • Cons: None significant

Option 3: Fix in getJSONValueFromString (Not chosen)

  • Location: libs/designer/src/lib/core/utils/parameters/helper.ts
  • Approach: Implement custom JSON parsing that understands expression tokens
  • Pros: Would handle edge cases in parsing
  • Cons:
    • Complex implementation requiring custom JSON parser
    • Fragile - would need to handle all expression formats
    • Treating symptoms rather than root cause
    • JSON.parse() correctly rejects invalid JSON; the problem is we're generating invalid JSON

Solution

Added a check in convertValueType: if a value contains tokens mixed with other content (i.e., compound expressions like @{var1}-@{var2}), treat it as a string type. This ensures insertQutationForStringType adds the necessary quotes around compound expressions to produce valid JSON.

// If value contains tokens mixed with other content (compound expressions like "@{var1}-@{var2}"),
// treat as string to produce valid JSON. Compound expressions must be quoted strings in JSON.
if (containsTokenSegments(value) && value.length > 1) {
  return constants.SWAGGER.TYPE.STRING;
}

Impact of Change

  • Users: Dictionary parameters with compound token expressions will serialize correctly
  • Developers: None - this is a transparent fix
  • System: Workflows using SQL Insert Row (and other dictionary operations) with compound expressions will now work correctly

Test Plan

  • Unit tests added/updated
  • E2E tests added/updated
  • Manual testing completed
  • Tested in: Local (unit tests)

Contributors

Screenshots/Videos

…pressions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 24, 2026 17:50
@github-actions
Copy link

github-actions bot commented Jan 24, 2026

🤖 AI PR Validation Report

PR Review Results

Thank you for your submission! Here's detailed feedback on your PR title and body compliance:

PR Title

  • Current: fix(designer-ui): Fix dictionary serialization with compound token expressions
  • Issue: None — title is clear, follows conventional commit style, and describes the change and scope.
  • Recommendation: No change needed.

Commit Type

  • Properly selected (fix).
  • Only one type selected which is correct for this change.

Risk Level

  • Risk level in PR body: Medium.
  • Label present: risk:medium.
  • Assessment: The PR body and repository label match (risk:medium).

What & Why

  • Current: Detailed description present: Problem, Root Cause, Options analyzed, and chosen Solution with code snippet.
  • Issue: None — explanation is thorough and includes root cause and rationale for chosen fix.
  • Recommendation: No change needed.

Impact of Change

  • Impact sections are present and clear.
  • Recommendation: Keep as-is.
    • Users: Dictionary parameters with compound token expressions will serialize correctly.
    • Developers: No API changes; transparent fix.
    • System: Workflows using dictionary operations (e.g., SQL Insert Row) will behave correctly with compound expressions.

Test Plan

  • Unit tests were claimed and a unit test file was added in the diff (libs/designer-ui/.../__test__/keyvalueitem.spec.ts).
  • The tests exercise convertValueType and convertKeyValueItemToSegments and assert that compound expression values are quoted in generated JSON.
  • E2E tests were not added (unchecked) — acceptable for this focused logic fix. If you believe a broader integration regression could occur, add an E2E or manual verification note.

⚠️ Contributors

  • The Contributors section is empty.
  • Recommendation: If others (PMs/designers/engineers) contributed, add them to the Contributors section or add a short acknowledgement. This is optional and won't block the PR.

Screenshots/Videos

  • Not applicable for this non-visual change — OK to be blank.

Summary Table

Section Status Recommendation
Title No change needed.
Commit Type No change needed.
Risk Level Label matches PR body, but see advised risk note below.
What & Why No change needed.
Impact of Change No change needed.
Test Plan Unit tests present and relevant.
Contributors ⚠️ Add acknowledgements if applicable.
Screenshots/Videos Not applicable.

Advised risk comparison and final notes

  • Advised risk level (reviewer): low — reasoning: the code change is small and targeted (a short conditional in convertValueType), limited to designer-ui utils, and supported by unit tests that were added. The diff shows 2 files changed, focused logic change with unit tests added.
  • PR-assigned risk level: medium (label risk:medium).
  • Actionable suggestion: If your team agrees with this assessment, consider updating the PR label to risk:low. If there are broader concerns (backwards-compatibility with unexpected callers, cross-repo impacts), keep risk:medium and call out the areas of concern.

Final decision: This PR passes the PR title and body checks. Please consider adding contributor acknowledgements (if relevant) and optionally updating the risk label to risk:low if aligned with your team's risk policy. Thank you for the thorough description and for adding unit tests — this made review straightforward.


Last updated: Sun, 25 Jan 2026 17:31:36 GMT

Copy link
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 fixes a bug where dictionary parameters with compound token expressions (e.g., @{variables('year')}-@{variables('month')}-@{variables('date')}) were incorrectly serialized as string literals instead of proper JSON objects, causing runtime failures.

Changes:

  • Modified convertValueType function to detect compound token expressions (multiple segments with tokens) and treat them as string type for proper JSON quoting
  • Added comprehensive unit tests covering the fix and related edge cases

Reviewed changes

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

File Description
libs/designer-ui/src/lib/editor/base/utils/keyvalueitem.ts Added 4-line check to treat compound expressions (tokens mixed with other content) as string type to ensure proper JSON serialization with quotes
libs/designer-ui/src/lib/editor/base/utils/__test__/keyvalueitem.spec.ts New test file with comprehensive coverage testing convertValueType and convertKeyValueItemToSegments functions, validating the fix for compound expressions, single tokens, literals, and empty cases

@github-actions
Copy link

📊 Coverage check completed. See workflow run for details.

@takyyon takyyon added the risk:medium Medium risk change with potential impact label Jan 25, 2026
@github-actions
Copy link

📊 Coverage check completed. See workflow run for details.

@takyyon takyyon enabled auto-merge (squash) January 25, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-validated risk:medium Medium risk change with potential impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants