fix: combine date bounds into a single --created range expression#31514
Merged
Conversation
…g bug Replace the three separate --created flag appends in listWorkflowRunsWithPagination with a single buildCreatedFilter helper that combines StartDate, EndDate, and BeforeDate into one --created expression. gh run list treats --created as a single string flag (StringVarP); supplying it multiple times only keeps the last value, silently discarding earlier bounds. This caused runs outside the requested --start-date/--end-date window to be returned. The fix uses GitHub's range syntax (start..end) when both a lower and upper bound are present. For the pagination cursor (BeforeDate, which is an exclusive upper bound), one second is subtracted before building the inclusive range so that the boundary run is not returned again on the next page. 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] Fix gh aw logs date-range filtering returning incorrect runs
fix: combine date bounds into a single May 11, 2026
--created range expression
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes gh run list date filtering by ensuring all provided date bounds are applied via a single --created flag value (since the upstream flag only retains the last occurrence), including pagination support via an exclusive BeforeDate cursor.
Changes:
- Added
buildCreatedFilter(startDate, endDate, beforeDate string) stringto collapse multiple date bounds into one GitHub-compatible range expression. - Updated
listWorkflowRunsWithPaginationto emit exactly one--createdargument built from all applicable bounds. - Added unit tests covering all bound combinations and a regression test to ensure
StartDateis never dropped.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/logs_github_api.go | Introduces buildCreatedFilter and switches gh run list arg construction to use a single combined --created expression. |
| pkg/cli/logs_github_api_test.go | Adds unit tests for buildCreatedFilter, including regression coverage for the original “StartDate silently dropped” bug. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug Fix
What was the bug?
gh run listtreats--createdas aStringVarP(single string), so passing it multiple times only keeps the last value.listWorkflowRunsWithPaginationwas appending one flag per bound:This meant
--start-datewas never enforced, allowing runs from arbitrarily early dates to be returned.How did you fix it?
Added
buildCreatedFilter(startDate, endDate, beforeDate string) stringthat collapses all bounds into a single--createdvalue using GitHub's range syntax:startDate+endDatestart..endstartDate+beforeDate(pagination)start..(beforeDate − 1s)startDateonly>=startendDateonly<=endbeforeDateonly<beforeDateBeforeDateis an exclusive pagination cursor; one second is subtracted before using it as the inclusive upper bound in range syntax, preventing the boundary run from reappearing on the next page.Testing
Unit tests added in
logs_github_api_test.gocovering all bound combinations, including a dedicated regression test (TestBuildCreatedFilterStartDateAlwaysEnforced) that asserts the lower bound is always present in the emitted filter string.