Skip to content

fix(concerto-cto): escape ObjectProperty default values in Printer.toCTO (closes #1636) - #1637

Open
Shawnn08 wants to merge 2 commits into
accordproject:mainfrom
Shawnn08:fix/cto-printer-escape-object-default
Open

Shawnn08 wants to merge 2 commits into
accordproject:mainfrom
Shawnn08:fix/cto-printer-escape-object-default

Conversation

@Shawnn08

Copy link
Copy Markdown
Contributor

Closes #1636

Ensures ObjectProperty default values are safely escaped via toStringLiteral() in Printer.toCTO, preventing broken syntax and preserving AST-to-CTO round-trip parsing when default values contain quotes or backslashes.

Changes

  • In packages/concerto-cto/src/printer.ts, replaced raw template string interpolation (default="${mm.defaultValue}") with default=${toStringLiteral(mm.defaultValue)} for ObjectProperty.
  • Added unit tests in packages/concerto-cto/test/printer.js verifying:
    • Quotes and backslashes in ObjectProperty default values are escaped.
    • Printed CTO for ObjectProperty with quotes successfully parses back to the original AST via Parser.parse.

Flags

  • None. This aligns ObjectProperty with StringProperty, StringScalar, and DateTimeProperty.

Screenshots or Video

N/A (CTO code generator fix)

Related Issues

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from fork:branchname

Signed-off-by: Shreyansh Giri <girilakshmi91@gmail.com>
@mira-accord-project

Copy link
Copy Markdown

Thank you for the pull request, and for linking it to issue #1636. We have requested review from the Concerto maintainers Jonathan Casey, Jamie Shorten, Stefan Blaginov and Ertugrul Karademir. A maintainer will review the change and reply here. If anything is unclear in the meantime, please ask in this thread.


Posted automatically by Mira, an Accord Project agent. A maintainer will follow up; they make the decisions on this.

@mira-accord-project mira-accord-project Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix, @Shawnn08. Using toStringLiteral for ObjectProperty defaults makes them consistent with StringProperty, StringScalar and DateTimeProperty, and it fixes the broken output for values containing quotes. The Parser.parse round-trip test is a good addition. CI is green and I found nothing blocking. Two optional nits are below. It needs a maintainer's approval before it can merge.

Nothing blocking; some suggestions below. Findings: 2 nit.

  • nit · hygiene: Open PR #1601 also escapes ObjectProperty default values with toStringLiteral in printer.ts, as one of several null-handling fixes. The two PRs will conflict on the same line, so whichever merges second will need a rebase, or the overlapping change can be dropped from one of them.

Automated review by Mira, an Accord Project agent, at d96d960. Findings are labelled blocking, should-fix or nit; a maintainer makes the final call.

Comment thread packages/concerto-cto/test/printer.js Resolved
… tests

Signed-off-by: Shreyansh Giri <girilakshmi91@gmail.com>

This branch has not been deployed

No deployments
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.

fix(concerto-cto): Printer.toCTO uses unescaped string interpolation for ObjectProperty default values

1 participant