ShivamSharma43 opened a new issue, #9356:
URL: https://github.com/apache/devlake/issues/9356

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/devlake/issues?q=is%3Aissue) and found no 
similar issues.
   
   ### What happened
   
   The Opsgenie and PagerDuty `collectIncidents` subtasks report success 
without collecting anything when their collector can't be created.
   
   Both `CollectIncidents` functions 
(`plugins/opsgenie/tasks/incidents_collector.go`, 
`plugins/pagerduty/tasks/incidents_collector.go`) drop the error returned by 
`api.NewStatefulApiCollectorForFinalizableEntity`:
   
   ```go
   collector, err := 
api.NewStatefulApiCollectorForFinalizableEntity(api.FinalizableApiCollectorArgs{
        ...
   })
   if err != nil {
        return nil
   }
   return collector.Execute()
   ```
   
   The constructor fails when, for example, it can't load the previous 
collector state from `_devlake_collector_latest_state`, or when the 
`BuildInputIterator` cursor over unfinished incidents fails in an incremental 
run. In those cases the subtask returns `nil`, the pipeline marks it as 
successful, and the extractor and converter run on whatever raw data is already 
there. No error is logged, so the user only sees that incidents stop updating.
   
   The other collectors of both plugins (Opsgenie `collectTeams` and 
`collectUsers`) return the error.
   
   ### What do you expect to happen
   
   `collectIncidents` fails with the constructor's error, like the other 
collectors.
   
   ### How to reproduce
   
   Make `NewStatefulApiCollectorForFinalizableEntity` fail, e.g. make the 
`First` query on the collector state table return an error (a unit test with a 
mocked `dal.Dal` does this). `CollectIncidents` returns `nil`.
   
   ### Anything else
   
   Proposed fix (I have a PR ready): `return err` instead of `return nil` in 
both collectors.
   
   ### Version
   
   main
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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