ソースを参照

fix: Nil binding on entity logs caused a NPE

jamesread 5 ヶ月 前
コミット
0e0bbd3fdb
2 ファイル変更11 行追加2 行削除
  1. 2 2
      service/internal/api/api.go
  2. 9 0
      service/internal/executor/executor.go

+ 2 - 2
service/internal/api/api.go

@@ -307,11 +307,11 @@ func (api *oliveTinAPI) internalLogEntryToPb(logEntry *executor.InternalLogEntry
 		ExecutionStarted:         logEntry.ExecutionStarted,
 		ExecutionFinished:        logEntry.ExecutionFinished,
 		User:                     logEntry.Username,
-		BindingId:                logEntry.Binding.ID,
+		BindingId:                logEntry.GetBindingId(),
 		DatetimeRateLimitExpires: calculateRateLimitExpires(api, logEntry),
 	}
 
-	if !pble.ExecutionFinished {
+	if !pble.ExecutionFinished && logEntry.Binding != nil && logEntry.Binding.Action != nil {
 		pble.CanKill = acl.IsAllowedKill(api.cfg, authenticatedUser, logEntry.Binding.Action)
 	}
 

+ 9 - 0
service/internal/executor/executor.go

@@ -111,6 +111,15 @@ type InternalLogEntry struct {
 	ActionIcon  string
 }
 
+// .Binding can be nil, so we need to handle that.
+func (e *InternalLogEntry) GetBindingId() string {
+	if e.Binding == nil {
+		return ""
+	}
+
+	return e.Binding.ID
+}
+
 type executorStepFunc func(*ExecutionRequest) bool
 
 // DefaultExecutor returns an Executor, with a sensible "chain of command" for