fix: Nil binding on entity logs caused a NPE

This commit is contained in:
jamesread 2026-01-26 00:34:39 +00:00
parent 912e6cfeb0
commit 0e0bbd3fdb
2 changed files with 11 additions and 2 deletions

View File

@ -307,11 +307,11 @@ func (api *oliveTinAPI) internalLogEntryToPb(logEntry *executor.InternalLogEntry
ExecutionStarted: logEntry.ExecutionStarted, ExecutionStarted: logEntry.ExecutionStarted,
ExecutionFinished: logEntry.ExecutionFinished, ExecutionFinished: logEntry.ExecutionFinished,
User: logEntry.Username, User: logEntry.Username,
BindingId: logEntry.Binding.ID, BindingId: logEntry.GetBindingId(),
DatetimeRateLimitExpires: calculateRateLimitExpires(api, logEntry), 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) pble.CanKill = acl.IsAllowedKill(api.cfg, authenticatedUser, logEntry.Binding.Action)
} }

View File

@ -111,6 +111,15 @@ type InternalLogEntry struct {
ActionIcon string 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 type executorStepFunc func(*ExecutionRequest) bool
// DefaultExecutor returns an Executor, with a sensible "chain of command" for // DefaultExecutor returns an Executor, with a sensible "chain of command" for