fix: Copilot plugin - add backfill time window to ensure data consistency#8811
fix: Copilot plugin - add backfill time window to ensure data consistency#8811la-tamas wants to merge 1 commit intoapache:mainfrom
Conversation
chore: Add backfill time window to ensure data consistency (cherry picked from commit 52a9555b782860f9c8ba9db409bd56e0c8f58272)
|
Mind fixing conflicts? Hint: if you use copilot you can ask it to fix conflicts for you - https://github.blog/changelog/2026-03-26-ask-copilot-to-resolve-merge-conflicts-on-pull-requests/ |
There was a problem hiding this comment.
Pull request overview
Adds a lookback/backfill window to the GitHub Copilot metrics collectors so incremental runs retry recently-missed days (e.g., reports not yet generated around midnight), improving data consistency.
Changes:
- Rewinds incremental collection start by a fixed
reportLookbackDaysand further clamps daily metrics to a trailing backfill window (dailyMetricsTrailingBackfillDays). - Refactors report metadata parsing/downloading into shared helpers (
parseReportMetadataResponse,parseRawReportResponse,parseUserMetricsReportResponse). - Adds unit tests covering the new date-range/backfill behavior and metadata “empty/204” handling.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| backend/plugins/gh-copilot/tasks/report_download_helper.go | Introduces lookback/backfill constants and shared metadata/record collection helpers. |
| backend/plugins/gh-copilot/tasks/user_metrics_collector.go | Applies trailing backfill and uses shared user-metrics response parsing. |
| backend/plugins/gh-copilot/tasks/org_metrics_collector.go | Applies trailing backfill and switches to shared raw-report response parsing. |
| backend/plugins/gh-copilot/tasks/enterprise_metrics_collector.go | Applies trailing backfill and switches to shared raw-report response parsing. |
| backend/plugins/gh-copilot/tasks/metrics_collector_test.go | Adds tests for lookback/backfill and metadata parsing edge cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| snippet := string(body) | ||
| if len(snippet) > 200 { | ||
| snippet = snippet[:200] | ||
| } | ||
| logger.Error(err, "failed to parse report metadata, body=%s", snippet) |
There was a problem hiding this comment.
logReportMetadataParseError logs a snippet of the raw metadata response body. This metadata includes download_links (signed URLs), so on parse errors this can leak sensitive, time-limited URLs into logs. Please redact/remove download_links before logging, or log only non-sensitive fields (e.g., report_day/range and response size/status) instead of the raw body snippet.
| snippet := string(body) | |
| if len(snippet) > 200 { | |
| snippet = snippet[:200] | |
| } | |
| logger.Error(err, "failed to parse report metadata, body=%s", snippet) | |
| logger.Error(err, "failed to parse report metadata, body_size=%d bytes", len(body)) |
| } | ||
| reportRange := reportMetadataRange(meta) | ||
| if reportRange != "" { | ||
| logger.Info("No download links for report day=%s, skipping", reportRange) |
There was a problem hiding this comment.
The log message says report day=%s but reportMetadataRange() can return a range like start..end. Please adjust the wording (e.g., report=%s/range=%s) so logs remain accurate for both 1-day and multi-day metadata.
| logger.Info("No download links for report day=%s, skipping", reportRange) | |
| logger.Info("No download links for report=%s, skipping", reportRange) |
pr-type/bug-fix,pr-type/feature-development, etc.Summary
Add backfill time window to ensure data consistency for GitHub Copilot metrics collection.
GitHub reports are generated hours after midnight, so a midnight run gets 404 for the previous day.
Without a lookback buffer,
LatestSuccessStartadvances past the missed day permanently.This change introduces:
reportLookbackDaysconstant: extra days rewound from 'until' on incremental runsdailyMetricsTrailingBackfillDaysconstant: extends retries for delayed daily report generation\n-clampDailyMetricsStartForBackfillhelper to apply the trailing backfill window.Does this close any open issues?
Screenshots
Other Information
Any other information that is important to this PR.