diff --git a/core/goflow/flows.go b/core/goflow/flows.go index f8908489b..3082a8524 100644 --- a/core/goflow/flows.go +++ b/core/goflow/flows.go @@ -53,6 +53,11 @@ func CloneDefinition(data []byte, depMapping map[uuids.UUID]uuids.UUID) ([]byte, // MigrateDefinition migrates the given flow definition to the specified version func MigrateDefinition(cfg *runtime.Config, data []byte, toVersion *semver.Version) ([]byte, error) { + // if requested version only differs by patch from current version, use current version + if toVersion == nil || (toVersion.LessThan(definition.CurrentSpecVersion) && toVersion.Major() == definition.CurrentSpecVersion.Major() && toVersion.Minor() == definition.CurrentSpecVersion.Minor()) { + toVersion = definition.CurrentSpecVersion + } + f, err := migrations.MigrateToVersion(data, toVersion, MigrationConfig(cfg)) if err != nil { return nil, &FlowDefError{cause: err} diff --git a/core/goflow/flows_test.go b/core/goflow/flows_test.go index f9c965645..e3c33132b 100644 --- a/core/goflow/flows_test.go +++ b/core/goflow/flows_test.go @@ -64,7 +64,7 @@ func TestMigrateDefinition(t *testing.T) { v13_3_0 := testsuite.ReadFile("testdata/migrate/13.3.0.json") v13_4_0 := testsuite.ReadFile("testdata/migrate/13.4.0.json") v13_5_0 := testsuite.ReadFile("testdata/migrate/13.5.0.json") - v13_6_0 := testsuite.ReadFile("testdata/migrate/13.6.0.json") + //v13_6_0 := testsuite.ReadFile("testdata/migrate/13.6.0.json") v13_6_1 := testsuite.ReadFile("testdata/migrate/13.6.1.json") // 13.0 > 13.1 @@ -95,7 +95,7 @@ func TestMigrateDefinition(t *testing.T) { // 13.5 > 13.6 migrated, err = goflow.MigrateDefinition(rt.Config, migrated, semver.MustParse("13.6.0")) assert.NoError(t, err) - test.AssertEqualJSON(t, v13_6_0, migrated) + test.AssertEqualJSON(t, v13_6_1, migrated) // because we bump to the latest patch version // 13.6 > 13.6.1 migrated, err = goflow.MigrateDefinition(rt.Config, migrated, semver.MustParse("13.6.1"))