Skip to content

[Bug][gh-copilot] collectOrgMetrics fails with "error parsing response" for organization-1-day endpoint #8789

@breymander

Description

@breymander

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:

  1. Successfully parse the response from GET /orgs/{org}/copilot/metrics/reports/organization-1-day, or
  2. 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

  1. Deploy DevLake v1.0.3-beta10
  2. Create a gh-copilot connection with a classic PAT and an organization
  3. Add the connection to a blueprint and trigger a pipeline
  4. Observe collectOrgMetrics fails 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

  1. 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
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    component/pluginsThis issue or PR relates to pluginspriority/highThis issue is very importantseverity/p0This bug blocks key user journey and functiontype/bugThis issue is a bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions