Skip to content

Commit c5ad0ac

Browse files
Fix: Remove invalid GetText() call on CallToolResult
Simplify workflow jobs pagination to directly handle jobs array instead of trying to parse CallToolResult text content.
1 parent 3a88695 commit c5ad0ac

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

pkg/github/actions.go

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -505,27 +505,23 @@ func ListWorkflowJobs(getClient GetClientFn, t translations.TranslationHelperFun
505505
}
506506
defer func() { _ = resp.Body.Close() }()
507507

508-
// Note: This response includes optimization_tip, so we need to handle it differently
509-
// For now, we'll wrap jobs in pagination and include tip separately
510-
// Get the jobs array from the response
511-
paginatedJobs, err := CreatePaginatedResponse(jobs, pagination.Page)
512-
if err != nil {
513-
return nil, err
514-
}
515-
516-
// Parse the paginated response to add the tip
517-
var paginatedData PaginatedResponse
518-
if err := json.Unmarshal([]byte(paginatedJobs.GetText()), &paginatedData); err != nil {
519-
return paginatedJobs, nil // Return as-is if parsing fails
508+
// Handle pagination and add optimization tip
509+
hasMore := len(jobs.Jobs) > CursorPageSize
510+
jobsToReturn := jobs.Jobs
511+
if hasMore {
512+
jobsToReturn = jobs.Jobs[:CursorPageSize]
520513
}
521514

522515
response := map[string]any{
523-
"items": paginatedData.Items,
524-
"moreData": paginatedData.MoreData,
525-
"cursor": paginatedData.Cursor,
516+
"jobs": jobsToReturn,
517+
"moreData": hasMore,
526518
"optimization_tip": "For debugging failed jobs, consider using get_job_logs with failed_only=true and run_id=" + fmt.Sprintf("%d", runID) + " to get logs directly without needing to list jobs first",
527519
}
528520

521+
if hasMore {
522+
response["cursor"] = EncodeCursor(pagination.Page + 1)
523+
}
524+
529525
r, err := json.Marshal(response)
530526
if err != nil {
531527
return nil, fmt.Errorf("failed to marshal response: %w", err)

0 commit comments

Comments
 (0)