Repository navigation
[Bug][gh-copilot] collectOrgMetrics fails with "error parsing response" for organization-1-day endpoint #8789
Description
Search before asking
- I had searched in the issues and found no similar issues.
What happened
The collectOrgMetrics subtask in the gh-copilot plugin fails immediately with error parsing response when collecting organization-level Copilot usage metrics via the organization-1-day report endpoint. The error occurs for every configured organization, blocks the entire pipeline, and prevents other tasks (Jenkins, Jira, etc.) from completing.
Error from logs:
level=error msg=" [pipeline service] [pipeline #24] [task #5234] subtask collectOrgMetrics ended unexpectedly
Wraps: (2) error parsing response from orgs/REDACTED_ORG/copilot/metrics/reports/organization-1-day
Error types: (1) *hintdetail.withDetail (2) *errors.errorString"
The subtask completes in ~1 second (not a timeout), suggesting the GitHub API responds successfully but the response body cannot be unmarshalled into the expected reportMetadataResponse struct.
Environment:
- DevLake version: v1.0.3-beta10
- Database: MySQL (CloudSQL)
- Authentication: Classic PAT with scopes
manage_billing:copilot,read:enterprise,read:org - Copilot Metrics API policy: enabled
- PAT owner: organization owner
- Deployment: Helm on GKE
What do you expect to happen
The collectOrgMetrics subtask should either:
- Successfully parse the response from
GET /orgs/{org}/copilot/metrics/reports/organization-1-day, or - Provide a clear error message including the HTTP status code and response body when parsing fails (e.g., "unexpected response format, expected JSON object with download_links")
How to reproduce
- Deploy DevLake v1.0.3-beta10
- Create a
gh-copilotconnection with a classic PAT and an organization - Add the connection to a blueprint and trigger a pipeline
- Observe
collectOrgMetricsfails with "error parsing response"
Analysis
The ResponseParser in org_metrics_collector.go expects the response to unmarshal into a reportMetadataResponse struct (containing DownloadLinks). The GitHub API at GET /orgs/{org}/copilot/metrics/reports/organization-1-day?day=YYYY-MM-DD may be returning a response in a format that doesn't match this struct.
Additionally, this error is fatal — it causes the entire pipeline to fail, blocking unrelated tasks like Jenkins and Jira collection that run in the same pipeline stage.
Suggested improvements
- Add verbose logging of the raw response body (or at least the HTTP status code and first N bytes) when parsing fails, to make debugging easier
- Validate the response format and provide a clear error message (e.g., "unexpected response format, expected JSON object with download_links")
Version
v1.0.3-beta10
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
breymander commentedon Mar 23, 2026
Root Cause
Figured out what's going on. On first run,
computeReportDateRangeinreport_download_helper.goiterates 365 days back (reportMaxDays = 365), but the Copilot Usage Metrics Reports API only has data going back to around Deccember 2025. For dates before that, GitHub doesn't return a404— it returns a200with body"":The
ignore404callback inreport_download_helper.goonly handles 404s, so this 200 passes straight through to theResponseParserinorg_metrics_collector.go, which does:Unmarshaling
""into a struct fails, and the framework wraps it as the generic "error parsing response" message.Suggested fix: Check for empty/non-object bodies (
"",null, empty) before the unmarshal and skip the day instead of erroring out. Same issue applies touser_metrics_collector.goandenterprise_metrics_collector.go.breymander commentedon Mar 23, 2026
I've created PR #8804 for review.
fix(gh-copilot): skip empty report responses for dates without Copilo…
Sync upstream Apache DevLake (v1.0.3-beta9 → beta15) (#22)