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

   ### 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 CircleCI `collectPipelines` subtask fails with `runtime error: invalid 
memory address or nil pointer dereference` when the sync policy has no 
`timeAfter`.
   
   `CollectPipelines` (`plugins/circleci/tasks/pipeline_collector.go`) reads 
the time range and dereferences it for every pipeline in the response:
   
   ```go
   timeAfter := rawDataSubTaskArgs.Ctx.TaskContext().SyncPolicy().TimeAfter
   ...
   if pipelineCreatedAt.Before(*timeAfter) {
        return filteredItems, api.ErrFinishCollect
   }
   ```
   
   `SyncPolicy.TimeAfter` is optional. It is `nil` for advanced mode blueprints 
(config-ui creates them with `timeAfter: undefined`), when the start date is 
cleared in the blueprint's sync policy, and for `directrun` without a 
`timeAfter`. As soon as the first page has a pipeline, the response parser 
panics, the worker scheduler records the panic as the task error, and no 
CircleCI data is collected.
   
   ### What do you expect to happen
   
   With no `timeAfter`, every pipeline is collected, like the other collectors 
do (the collector framework already treats a missing `timeAfter` as "no lower 
bound").
   
   ### How to reproduce
   
   1. Create an advanced mode blueprint with a CircleCI project, or clear the 
start date of a normal blueprint's time range.
   2. Run it. `collectPipelines` fails with the nil pointer dereference.
   
   ### Anything else
   
   Proposed fix (I have a PR ready): only filter by `timeAfter` when it is set, 
and check that `SyncPolicy()` isn't `nil` before reading it.
   
   ### 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