breymander opened a new pull request, #8804:
URL: https://github.com/apache/incubator-devlake/pull/8804

   ## Summary
   
   GitHub's Copilot Usage Metrics Reports API returns HTTP 200 with body `""` 
for dates before usage data was available, instead of returning a 404. The 
existing `ignore404` callback does not catch this, so the `ResponseParser` 
attempts `json.Unmarshal` on `""` which fails and crashes the collector 
pipeline.
   
   **Changes:**
   - Add an `isEmptyReport(body []byte) bool` helper in 
`report_download_helper.go` that detects empty, `""`, or `null` bodies
   - Guard the `ResponseParser` in all three collectors 
(`enterprise_metrics_collector.go`, `org_metrics_collector.go`, 
`user_metrics_collector.go`) to return `nil, nil` when an empty report is 
detected, so the collector silently skips those days
   - Add unit tests for `isEmptyReport` covering empty body, `""`, `null`, 
whitespace, and valid metadata cases
   
   Fixes #8789
   
   ## Test Plan
   - [x] Unit tests added for `isEmptyReport` covering edge cases (empty body, 
`""`, `null`, whitespace, valid JSON)
   - [ ] Manual verification: configure a Copilot connection with a `since` 
date predating available usage data and confirm the collector no longer crashes
   
   Made with [Cursor](https://cursor.com)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to