Skip to content

fix: accept DSL versions from 1.0.0 up to the SDK's schema version#267

Merged
ricardozanini merged 2 commits into
serverlessworkflow:mainfrom
lornakelly:dsl-version-bug
Jun 25, 2026
Merged

fix: accept DSL versions from 1.0.0 up to the SDK's schema version#267
ricardozanini merged 2 commits into
serverlessworkflow:mainfrom
lornakelly:dsl-version-bug

Conversation

@lornakelly

@lornakelly lornakelly commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Closes #266

What this PR does / why we need it:

Fixes DSL version validation rejecting valid older workflows. The hook compared the workflow's dsl against the SDK's schemaVersion (1.0.3) with strict equality (!==), so only accepted workflows with dsl: "1.0.3" and rejected 1.0.0/1.0.1/1.0.2

Changes:

  • Add semver package
  • Add supportedDslVersions range to package.json
  • Validate dsl against supported range
  • Allow pre release versions

Comment thread src/lib/hooks/workflow-hooks.ts Outdated

import { schemaVersion } from '../../../package.json';

const compareVersions = (a: string, b: string) => a.localeCompare(b, undefined, { numeric: true });

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.

In the Java SDK, we use a semver lib to compare versions. I'm not familiar with localeCompare, does it do the same?

@lornakelly lornakelly Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not exactly the same, here the main difference is that semver knows about pre release tags so knows 1.0.3-alpha < 1.0.3, localCompare treats it the opposite because it is compares the numbers and sees 1.0.3 as the maximum but then assumes, because it is a longer string, it is greater than the allowed version

I went with the simpler built in localeCompare as I thought it overkill to add a new package dependency for this because I saw in package.json that the schemaVersion field is in the format major.minor.patch, its the version field that has the tag which we are not comparing https://github.com/serverlessworkflow/sdk-typescript/blob/main/package.json#L3

What I didnt take into account though is do people add tags in the workflow document dsl field?, so something like dsl: 1.0.3-alpha? If that is the case I would need to change this to use semver instead as with localeCompare that would get rejected today

I could also change it if you would rather consistency with Java sdk?

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.

I agree with @ricardozanini, I'd rather use semver as well. Could you please look at my comment in the issue and align your implementation with it?

(reasoning: if the schema was 2.0.0, which breaks with 1.0.0, the current code would still show a green ligth)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes will do, thanks for the feedback

Comment thread src/lib/hooks/workflow-hooks.ts Outdated

import { schemaVersion } from '../../../package.json';

const compareVersions = (a: string, b: string) => a.localeCompare(b, undefined, { numeric: true });

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.

I agree with @ricardozanini, I'd rather use semver as well. Could you please look at my comment in the issue and align your implementation with it?

(reasoning: if the schema was 2.0.0, which breaks with 1.0.0, the current code would still show a green ligth)

@JBBianchi

Copy link
Copy Markdown
Member

I forgot to mention, please also bump the version of the package to v1.0.3-alpha2

lornakelly and others added 2 commits June 25, 2026 14:42
Signed-off-by: lornakelly <lornakelly88@gmail.com>
Signed-off-by: Lorna Kelly <lornakelly@Lornas-MacBook-Pro.local>

@JBBianchi JBBianchi 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.

Nice work, thank you @lornakelly

@ricardozanini ricardozanini merged commit 33818d0 into serverlessworkflow:main Jun 25, 2026
2 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.

DSL version validation rejects compatible 1.0.x workflows

3 participants