Skip to content

Conversation

@AlekseyManetov
Copy link
Contributor

Proposed Changes

Closes #176

The issue was in wrong template validation for case when template without version and with '0' version was assumed as duplicates. In this case template with '0' version was not added to the valid templates list and wasn't proposed for the update. For all other cases, e.g. template without version and template with version > 0, update logic worked as expected.

Checklist

Ensure you provide everything we need to review your contribution:

  • Contribution meets our definition of done
  • Pull request establishes context
    • Link to related issue(s), i.e. Closes {LINK_TO_ISSUE} or Related to {LINK_TO_ISSUE}
    • Brief textual description of the changes
    • Screenshots or short videos showing UI/UX changes
    • Steps to try out, i.e. using the @bpmn-io/sr tool

Copilot AI review requested due to automatic review settings January 30, 2026 13:12
@bpmn-io-tasks bpmn-io-tasks bot added the needs review Review pending label Jan 30, 2026
@AlekseyManetov AlekseyManetov requested review from a team, jarekdanielak and philippfromme and removed request for a team January 30, 2026 13:12
@AlekseyManetov AlekseyManetov requested a review from barmac January 30, 2026 13:12
Copy link

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 in template validation where templates without a version and templates with version 0 were incorrectly treated as duplicates. Previously, the code used template.version || '_' which converted the falsy value 0 to '_', causing version 0 templates to collide with unversioned templates. The fix changes this to use isNil(template.version) ? '_' : template.version, which only treats null and undefined as "no version" while preserving 0 as a valid version value.

Changes:

  • Updated version checking logic in both element-templates and cloud-element-templates validators to use isNil() instead of falsy checks
  • Added test cases to verify templates with no version and version 0 are treated as distinct
  • Updated test fixtures and BPMN diagrams to support the new test scenarios

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/element-templates/Validator.js Updated _validateTemplate to use isNil() for version checking; imported isNil from min-dash
src/cloud-element-templates/Validator.js Updated _validateTemplate to use isNil() for version checking; imported isNil from min-dash
test/spec/element-templates/Validator.spec.js Added test case verifying templates with no version and version 0 are accepted as different versions
test/spec/cloud-element-templates/Validator.spec.js Added test case verifying templates with no version and version 0 are accepted as different versions
test/spec/cloud-element-templates/fixtures/falsy-version.json Updated fixture to include both a template without version and a template with version 0
test/spec/cloud-element-templates/fixtures/complex.bpmn Added a task element referencing the falsy-template for integration testing
CHANGELOG.md Added entry documenting the bug fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AlekseyManetov AlekseyManetov force-pushed the 176-fix-non-version-template-update branch from 6d6424f to 2a90321 Compare January 30, 2026 13:27
@AlekseyManetov AlekseyManetov force-pushed the 176-fix-non-version-template-update branch from 2a90321 to fa248bf Compare January 30, 2026 16:09
@philippfromme philippfromme force-pushed the 176-fix-non-version-template-update branch from fa248bf to caa7f36 Compare January 30, 2026 17:08
@philippfromme philippfromme changed the title fix: fixed wrong template validation for case when template without version and with '0' version was assumed as duplicates Handle version 0 correctly during validation Jan 30, 2026
@philippfromme philippfromme self-requested a review January 30, 2026 17:10
Copy link
Contributor

@philippfromme philippfromme left a comment

Choose a reason for hiding this comment

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

Looks good! ✅ I simplified the changelog entry a little bit and adjusted the commit messages. We always want to make sure we mention the issue in the commit message (e.g. Closes #123).

@philippfromme philippfromme merged commit 4345d2a into main Jan 30, 2026
5 checks passed
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Jan 30, 2026
@philippfromme philippfromme deleted the 176-fix-non-version-template-update branch January 30, 2026 17:13
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.

Add updating option to element templates without versions

3 participants