Skip to content

Commit 018b45f

Browse files
committed
Fix handle more errors
1 parent 8998c09 commit 018b45f

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

actionsdotnetactcompat/act_worker.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ func (f *ghaFormatter) Format(entry *logrus.Entry) ([]byte, error) {
161161
if f.rqt.MaskHints != nil {
162162
for _, v := range f.rqt.MaskHints {
163163
if strings.EqualFold(v.Type, "regex") {
164-
r, _ := regexp.Compile(v.Value)
164+
r, err := regexp.Compile(v.Value)
165+
if err != nil {
166+
// TODO precompile regex and log errors
167+
continue
168+
}
165169
msg = r.ReplaceAllString(msg, "***")
166170
}
167171
}
@@ -244,7 +248,11 @@ func ExecWorker(rqt *protocol.AgentJobRequestMessage, wc actionsrunner.WorkerCon
244248
}
245249
actLogger.SetFormatter(formatter)
246250
actLogger.Println("Initialize translating the job request to actions-oss/act-cli (nektos/act)")
247-
vssConnection, vssConnectionData, _ := rqt.GetConnection("SystemVssConnection")
251+
vssConnection, vssConnectionData, conErr := rqt.GetConnection("SystemVssConnection")
252+
if conErr != nil {
253+
wc.FailInitJob("Failed to initialize Job", conErr.Error())
254+
return
255+
}
248256
if jlogger.Connection != nil {
249257
vssConnection.Client = jlogger.Connection.Client
250258
vssConnection.Trace = jlogger.Connection.Trace
@@ -334,8 +342,10 @@ func ExecWorker(rqt *protocol.AgentJobRequestMessage, wc actionsrunner.WorkerCon
334342
return
335343
}
336344
var payload string
337-
{
338-
e, _ := json.Marshal(githubCtxMap["event"])
345+
if e, err := json.Marshal(githubCtxMap["event"]); err != nil {
346+
failInitJob(fmt.Sprintf("cannot convert github.event to json: %w", err))
347+
return
348+
} else {
339349
payload = string(e)
340350
}
341351
unixHostPrefix := "unix://"

0 commit comments

Comments
 (0)