Skip to content

Commit 227ec69

Browse files
handle 'unexpected end of JSON input' for settings file
1 parent c282b11 commit 227ec69

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/app/app.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"os"
88
"os/signal"
9+
"strings"
910
"syscall"
1011
"time"
1112

@@ -120,7 +121,9 @@ func NewApp(ctx context.Context, opts *ApplicationOptions) error {
120121
// read the settings file
121122
settingsData, err := os.ReadFile(opts.SettingsFile)
122123
if err != nil {
123-
if os.IsNotExist(err) {
124+
// The file doesn't exist or is not completely written to the system, i.e., not a vaild
125+
// json file, we will continue on the retry.
126+
if os.IsNotExist(err) || strings.Contains(err.Error(), "unexpected end of JSON input") {
124127
continue
125128
}
126129
log.Logger().Errorf("failed to read settings file: %v", err)

0 commit comments

Comments
 (0)