Skip to content

fix(concerto-cto): reject duplicate validators instead of silently keeping the last - #1314

Merged
mttrbrts merged 1 commit into
accordproject:mainfrom
rajanpanth:fix/duplicate-validators-rejected
Sep 3, 2026
Merged

mttrbrts merged 1 commit into
accordproject:mainfrom
rajanpanth:fix/duplicate-validators-rejected

Conversation

@rajanpanth

Copy link
Copy Markdown
Contributor

Changes

Executed comparison, old parser (HEAD~1 grammar) vs current main:

dup regex (field)   | old: rejected | main: ACCEPTED, kept pattern "b"
dup length (field)  | old: rejected | main: ACCEPTED, kept [30,40]
dup range (field)   | old: rejected | main: ACCEPTED, kept [500,600]
dup size (field)    | old: rejected | main: ACCEPTED, kept [9,10]
dup regex (scalar)  | old: rejected | main: ACCEPTED, kept pattern "b"

Tests

Seven cases added under the validator ordering describe in test/parserMain.js: duplicate regex and length on a String field, duplicate range on Integer, Double and Long, duplicate size on an array, and duplicate regex on a scalar. With the grammar and generated parser reverted and the tests kept, all seven fail with expected [Function] to throw an error; restored, the concerto-cto suite passes 177/177 and every any-order valid case from #1305 still parses. eslint clean.

…eping the last

The any-order validator collection introduced in accordproject#1305 buckets validators
by $class with plain assignment, so regex=/a/ regex=/b/ now parses and
silently drops /a/. The same applies to length, range and size, on both
fields and scalars; before accordproject#1305 the grammar rejected all of these. A
modeler's constraint being silently discarded weakens validation.

The grammar initializer gains a bucketValidators helper that raises a
located 'Duplicate <kind> validator' error on a repeat, used by all five
reducer rules. src/parser.js regenerated with npm run parser, matching the
convention of committing the generated parser.

Seven tests added covering duplicate regex, length, range (Integer, Double,
Long) and size on fields plus regex on a scalar; all fail on the unfixed
grammar and every any-order valid case from accordproject#1305 still parses.

Signed-off-by: rajanpanth <rajan.pantha@samriddhicollege.edu.np>
Copilot AI lite review requested due to automatic review settings September 3, 2026 06:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change restores correct duplicate-validator rejection with targeted tests and includes the regenerated parser to match the updated grammar.

Pull request overview

Restores the pre-#1305 behavior of rejecting duplicate validators (regex/length/range/size) during parsing, preventing silent “last-wins” constraint weakening while keeping validator ordering flexible.

Changes:

  • Added bucketValidators helper to detect and throw on duplicate validator kinds during reduction.
  • Updated validator collection reducers to use bucketValidators instead of last-wins assignment.
  • Added regression tests for duplicate validators and regenerated the committed parser output.
File summaries
File Description
packages/concerto-cto/test/parserMain.js Adds regression tests ensuring duplicate validators are rejected.
packages/concerto-cto/src/parser.pegjs Introduces bucketValidators and applies it to validator-bucketing grammar rules.
packages/concerto-cto/src/parser.js Regenerated parser output reflecting the updated grammar logic.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mttrbrts mttrbrts left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You're on a roll @rajanpanth . Thanks!

cc: @muhabdulkadir

@mttrbrts
mttrbrts enabled auto-merge (squash) September 3, 2026 09:44
@mttrbrts
mttrbrts merged commit 243a00b into accordproject:main Sep 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants