Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 20, 2025

✅ COMPLETE: Fix logs command filtering issue

Problem

The logs command was not finding all workflow runs when no workflow name was specified:

./gh-aw logs tidy -c 10    # Returns 10 runs ✓
./gh-aw logs -c 10          # Returns fewer than 10 runs ❌

Root Cause

Bug in pagination logic (pkg/cli/logs.go line 616):

if len(runs) < batchSize {  // WRONG: uses filtered count
    break  // Stops iteration prematurely
}

When searching all workflows:

  1. GitHub API returns 250 mixed runs (agentic + non-agentic)
  2. Filter to agentic workflows → only 5 match
  3. Check: len(filtered)=5 < batchSize=250STOP ❌ (incorrect!)
  4. Should: Check totalFetched=250 < batchSize=250CONTINUE

Solution

Modified listWorkflowRunsWithPagination to return:

  • Filtered workflow runs (agentic only)
  • Total count fetched from API (before filtering)

Fixed iteration logic:

if totalFetched < batchSize {  // CORRECT: uses API response count
    break  // Only stops when truly out of data
}

Changes Made

  • Modified function signature to return ([]WorkflowRun, int, error)
  • Added totalFetched tracking before filtering
  • Updated end-of-batch check to use totalFetched
  • Updated all error returns to include new parameter
  • Added comprehensive inline comments
  • Updated test to handle new return value
  • Created documentation tests in logs_filtering_test.go

Validation ✅

make build          # ✓ Compiles successfully
make test-unit      # ✓ All unit tests pass
make test           # ✓ All tests pass
make fmt            # ✓ Code formatted
make lint           # ✓ No linting issues
make agent-finish   # ✓ Complete validation passes

Impact

Consistent behavior: ./gh-aw logs -c 10 now returns 10 runs
No performance impact: Same efficient batch fetching
No breaking changes: CLI interface unchanged
Minimal code changes: Only 4 lines changed, rest are comments
Well documented: Inline comments + test file

Files Changed

  • pkg/cli/logs.go - Core fix with detailed comments
  • pkg/cli/logs_test.go - Updated test signature
  • pkg/cli/logs_filtering_test.go - Documentation tests

Testing

All tests pass, no regressions detected.

Original prompt

The "logs" command does not find all the runs when no workflow name is specified. Investigate when it is failing.

compare the output of ./gh-aw logs tidy -c 10 and ./gh-aw logs -c 10


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits October 20, 2025 23:19
When no workflow name is specified, the logs command was incorrectly
stopping iteration after the first batch if few agentic workflows were
found, even when more runs were available from GitHub.

Root cause: The end-of-data check was comparing the filtered runs count
against batch size, instead of the total API response size.

Fix: Modified listWorkflowRunsWithPagination to return both the filtered
runs and the total count fetched from API, then use totalFetched for
the end-of-data check instead of len(filtered runs).

This ensures the command iterates until it finds the requested number
of agentic workflow runs or truly reaches the end of GitHub data.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate logs command failure without workflow name Fix logs command not finding all runs when no workflow name is specified Oct 20, 2025
Copilot AI requested a review from pelikhan October 20, 2025 23:25
@pelikhan pelikhan marked this pull request as ready for review October 20, 2025 23:29
@github-actions
Copy link
Contributor

Agentic Changeset Generator triggered by this pull request.

@@ -0,0 +1,82 @@
# Logs Command Filtering Fix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in abb9288

@pelikhan pelikhan merged commit 3219dd0 into main Oct 20, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/investigate-logs-command-issue branch October 20, 2025 23:34
Copilot AI requested a review from pelikhan October 20, 2025 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants