Skip to content

Commit 5761ce3

Browse files
pedronassertreeder
authored andcommitted
fix: error unmarshal empty app config (#609)
1 parent a036563 commit 5761ce3

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

api/datastore/postgres/postgres.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import (
88

99
"context"
1010

11+
"bytes"
1112
"github.com/Sirupsen/logrus"
13+
"github.com/iron-io/functions/api/datastore/internal/datastoreutil"
1214
"github.com/iron-io/functions/api/models"
1315
"github.com/lib/pq"
1416
_ "github.com/lib/pq"
15-
"bytes"
16-
"github.com/iron-io/functions/api/datastore/internal/datastoreutil"
1717
)
1818

1919
const routesTableCreate = `
@@ -185,8 +185,8 @@ func (ds *PostgresDatastore) GetApp(ctx context.Context, name string) (*models.A
185185
Name: resName,
186186
}
187187

188-
if err := json.Unmarshal([]byte(config), &res.Config); err != nil {
189-
return nil, err
188+
if len(config) > 0 {
189+
json.Unmarshal([]byte(config), &res.Config)
190190
}
191191

192192
return res, nil
@@ -295,7 +295,6 @@ func (ds *PostgresDatastore) InsertRoute(ctx context.Context, route *models.Rout
295295
return err
296296
})
297297

298-
299298
if err != nil {
300299
return nil, err
301300
}
@@ -563,7 +562,6 @@ func (ds *PostgresDatastore) Get(ctx context.Context, key []byte) ([]byte, error
563562
return []byte(value), nil
564563
}
565564

566-
567565
func (ds *PostgresDatastore) Tx(f func(*sql.Tx) error) error {
568566
tx, err := ds.db.Begin()
569567
if err != nil {

0 commit comments

Comments
 (0)