This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch kw-normal-bp-json-error
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit ad8e21d2d54d5b7489a0e2e1a81489ceed171527
Author: Klesh Wong <[email protected]>
AuthorDate: Mon Oct 16 16:25:04 2023 +0800

    fix: normalize_bp_settings throws error
---
 .../core/models/migrationscripts/20230829_normalize_bp_settings.go   | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git 
a/backend/core/models/migrationscripts/20230829_normalize_bp_settings.go 
b/backend/core/models/migrationscripts/20230829_normalize_bp_settings.go
index 881dcb9bb..6de0155fc 100644
--- a/backend/core/models/migrationscripts/20230829_normalize_bp_settings.go
+++ b/backend/core/models/migrationscripts/20230829_normalize_bp_settings.go
@@ -74,7 +74,7 @@ func (script *normalizeBpSettings) Up(basicRes 
context.BasicRes) errors.Error {
        }
        db := basicRes.GetDal()
        bp := &blueprint20230829{}
-       cursor := errors.Must1(db.Cursor(dal.From("_devlake_blueprints")))
+       cursor := errors.Must1(db.Cursor(dal.From("_devlake_blueprints"), 
dal.Where("mode = ?", "NORMAL")))
        defer cursor.Close()
 
        for cursor.Next() {
@@ -82,6 +82,9 @@ func (script *normalizeBpSettings) Up(basicRes 
context.BasicRes) errors.Error {
                errors.Must(db.Fetch(cursor, bp))
                // decrypt and unmarshal settings
                settingsJson := errors.Must1(plugin.Decrypt(encKey, 
bp.Settings))
+               if settingsJson == "" {
+                       continue
+               }
                settings := &blueprintSettings20230829{}
                errors.Must(json.Unmarshal([]byte(settingsJson), settings))
                // update bp fields

Reply via email to