fix(describe): quote and escape MDL strings in one place (mendixlabs/mxcli#1006) - #348
Merged
Conversation
DESCRIBE WORKFLOW emitted single-quoted payloads without doubling the
quotes inside them, so its own output was a syntax error:
targeting users xpath '[System.UserRoles = '[%UserRole_Banker%]']'
-> line 6:48 mismatched input '[%UserRole_Banker%]' expecting ';'
The string terminates at `= '` and every later statement cascades, so
DESCRIBE WORKFLOW output could not be fed back to check or exec for any
workflow with an XPath-targeted user task.
The reported case is one of six. The emitters wrote
fmt.Sprintf("... '%s'", v)
with the quotes in the format string and the escaping, when present, as
a separate statement at the call site — one thing to remember per site,
and 6 of 23 sites did not do it: both `targeting … xpath` variants, the
user task caption, the workflow-level due date (the task-level one two
functions away does escape), and both outcome values. The caption needs
no XPath to reach: `Manager's review`.
mdlQuoted(s) now returns the complete literal, quotes included, so an
unescaped emit cannot be written by omission, and all 23 sites go
through it.
Tests assert the emitted MDL PARSES rather than that it contains a
particular escape — a substring assertion would encode the escape under
test and pass for the wrong reason. A source scan guards the class,
because emit tests only cover the positions they construct and the real
failure mode is a new site added later.
Reported as mendixlabs#1006 (the XPath variant only).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Fixes
mendixlabs/mxcli#1006.DESCRIBE WORKFLOWemitted single-quoted payloads without doubling the quotes inside them, so its own output was a syntax error:The string terminates at
= ', and every later statement cascades — so describe output could not be fed back tocheckorexecfor any workflow with an XPath-targeted user task.The reported case is one of six
The emitters wrote
fmt.Sprintf("… '%s'", v): quotes in the format string, escaping (when present) as a separate statement at the call site. That's one thing to remember per site, and 6 of 23 sites didn't:targeting users xpathtargeting groups xpathManager's review— no XPath neededdue dateWon't fixThe fix
mdlQuoted(s)returns the complete literal, quotes included, so an unescaped emit cannot be written by omission. All 23 sites now go through it; the file has zero remaining'%s'and zero remaining inlineReplaceAll.Tests
Four new tests, all verified to fail against the original emitters:
Two deliberate choices:
create workflow … end workflow;and runsvisitor.Build. It routes throughformatWorkflowActivitiesrather than the per-activity formatter, because the statement terminator is appended by the caller — calling the formatter directly produces unparseable output for reasons unrelated to the bug.'%s'alongside the emit tests. Emit tests only cover the positions the test constructs; the real failure mode is a new site added later.mdlQuotedcarrying its own quotes is what makes that scan sound rather than a style rule.Two sibling issues from the same reporter are separate PRs:
mendixlabs/mxcli#1007(annotations) and#1005(jump targets).🤖 Generated with Claude Code