Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changes/unreleased/Fixed-20251219-104159.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Fixed
body: Fixed task logs API to return a `last_entry_id` even if `after_entry_id` is the last entry.
time: 2025-12-19T10:41:59.153319-05:00
8 changes: 8 additions & 0 deletions server/internal/task/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,17 @@ func (s *Service) GetTaskLog(ctx context.Context, databaseID string, taskID uuid
log := &TaskLog{
DatabaseID: databaseID,
TaskID: taskID,
Entries: make([]LogEntry, 0, len(stored)),
}
for i := len(stored) - 1; i >= 0; i-- {
s := stored[i]
if s.EntryID == options.AfterEntryID {
// This range should be behave as if its exclusive, however we need
// to perform an inclusive get so that we're still able to return
// the last entry ID when there are no entries after AfterEntryID.
// Skipping this entry produces the expected behavior.
continue
}
log.Entries = append(log.Entries, LogEntry{
Timestamp: s.Timestamp,
Message: s.Message,
Expand Down
5 changes: 4 additions & 1 deletion server/internal/task/task_log_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ func (s *TaskLogEntryStore) GetAllByTaskID(databaseID string, taskID uuid.UUID,
opOptions = append(opOptions, clientv3.WithLimit(int64(options.Limit)))
}
if options.AfterEntryID != uuid.Nil {
rangeStart = s.Key(databaseID, taskID, options.AfterEntryID) + "0"
// We intentionally treat this as inclusive so that we still return an
// entry when AfterEntryID is the last entry. Callers must ignore the
// entry with EntryID == AfterEntryID.
rangeStart = s.Key(databaseID, taskID, options.AfterEntryID)
}
opOptions = append(
opOptions,
Expand Down