Skip to content

fix(workflows): Fix empty results in Workflows query type#526

Merged
zoltanbedi merged 5 commits intografana:mainfrom
idan-starkware:fix/workflows-empty-results-503
Nov 24, 2025
Merged

fix(workflows): Fix empty results in Workflows query type#526
zoltanbedi merged 5 commits intografana:mainfrom
idan-starkware:fix/workflows-empty-results-503

Conversation

@idan-starkware
Copy link
Contributor

Fixes #503

  • Add nil check for CreatedAt/UpdatedAt timestamps to prevent panics
  • Add 'None' option to Time Field dropdown (default) to return all workflows
  • Improve time filtering logic with better nil handling
  • Add debug logging for troubleshooting

Testing

  • ✅ All existing tests pass
  • ✅ Tested locally with docker-compose
  • ✅ Verified workflows are returned when Time Field is "None"
  • ✅ Verified time filtering works with CreatedAt/UpdatedAt options

@idan-starkware idan-starkware requested a review from a team as a code owner November 4, 2025 15:24
@CLAassistant
Copy link

CLAassistant commented Nov 4, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@zoltanbedi zoltanbedi left a comment

Choose a reason for hiding this comment

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

Thanks for creating this PR @idan-starkware. I tried it out and it worked as expected. Please create a changeset for this and also update the docs in docs/sources/query/_index.md.


// If time field is None, return all workflows without filtering
if opts.TimeField == models.WorkflowTimeFieldNone {
backend.Logger.Debug("GetWorkflows", "time_field_none", "returning_all_workflows")
Copy link
Member

Choose a reason for hiding this comment

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

We can figure it out from the debug log above that the time field is none.

Suggested change
backend.Logger.Debug("GetWorkflows", "time_field_none", "returning_all_workflows")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

shouldInclude = !createdAtTime.Before(timeRange.From) && !createdAtTime.After(timeRange.To)
if !shouldInclude {
excludedCount++
backend.Logger.Debug("keepWorkflowsInTimeRange", "workflow_excluded", *workflow.Name, "createdAt", createdAtTime, "timeRange", fmt.Sprintf("%v to %v", timeRange.From, timeRange.To))
Copy link
Member

Choose a reason for hiding this comment

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

Please remove this debug log. The summary debug log is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

shouldInclude = !updatedAtTime.Before(timeRange.From) && !updatedAtTime.After(timeRange.To)
if !shouldInclude {
excludedCount++
backend.Logger.Debug("keepWorkflowsInTimeRange", "workflow_excluded", *workflow.Name, "updatedAt", updatedAtTime, "timeRange", fmt.Sprintf("%v to %v", timeRange.From, timeRange.To))
Copy link
Member

Choose a reason for hiding this comment

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

Please remove this debug log. The summary debug log is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@idan-starkware idan-starkware force-pushed the fix/workflows-empty-results-503 branch from 18f2663 to df670e2 Compare November 23, 2025 08:13
Copy link
Member

@zoltanbedi zoltanbedi left a comment

Choose a reason for hiding this comment

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

@idan-starkware the debug logs made it back that @jcolladokuri removed. Please remove them.

Also please merge from main as I fixed the zizmor issues.

Fixes grafana#503

- Add nil check for CreatedAt/UpdatedAt timestamps to prevent panics
- Add 'None' option to Time Field dropdown (default) to return all workflows
- Improve time filtering logic with better nil handling
- Add debug logging for troubleshooting
- Add 'None' option to Time Field documentation
- Update sample queries to show both 'None' and 'CreatedAt' options
- Add changeset for the fix
- Remove time_field_none debug log (redundant with timeField in main log)
- Remove per-workflow exclusion logs (summary log is sufficient)
Remove all debug logging statements that were previously removed by jcolladokuri
@idan-starkware idan-starkware force-pushed the fix/workflows-empty-results-503 branch from 628678b to 2386c3d Compare November 24, 2025 13:56
Copy link
Member

@zoltanbedi zoltanbedi left a comment

Choose a reason for hiding this comment

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

Thank you @idan-starkware

@zoltanbedi zoltanbedi merged commit ca4ce75 into grafana:main Nov 24, 2025
18 checks passed
@github-project-automation github-project-automation bot moved this to Complete in OSS Big Tent Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

Empty result on Workflows query type

3 participants