ShivamSharma43 opened a new pull request, #9368:
URL: https://github.com/apache/devlake/pull/9368

   ### Summary
   
   The CircleCI `collectPipelines` subtask failed with `runtime error: invalid 
memory address or nil pointer dereference` when the sync policy had no 
`timeAfter`.
   
   Its response parser stopped at the first pipeline created before the time 
range:
   
   ```go
   timeAfter := rawDataSubTaskArgs.Ctx.TaskContext().SyncPolicy().TimeAfter
   ...
   if pipelineCreatedAt.Before(*timeAfter) {
   ```
   
   `SyncPolicy.TimeAfter` is optional. It is `nil` for advanced mode blueprints 
(config-ui creates them with `timeAfter: undefined`), when the start date of a 
blueprint's time range is cleared, and for `directrun` without a `timeAfter`. 
The parser then panicked on the first pipeline, the worker scheduler recorded 
the panic as the task error, and nothing was collected.
   
   Changes:
   
   - `tasks/pipeline_collector.go`:
     - The response parsing moves into `parsePipelines(res, timeAfter)`. With a 
`nil` `timeAfter` it returns every pipeline on the page; otherwise it filters 
as before.
     - `CollectPipelines` checks that `SyncPolicy()` isn't `nil` before reading 
`TimeAfter`, like the collector helpers do.
   - `tasks/pipeline_collector_test.go` (new): `parsePipelines` keeps every 
pipeline without a `timeAfter`, and stops with `ErrFinishCollect` at the first 
pipeline before it.
   
   ### Does this close any open issues?
   
   Closes #9367
   
   ### Screenshots
   
   N/A
   
   ### Other Information
   
   - `go test ./plugins/circleci/tasks/`: pass. With the old parsing body, 
`TestParsePipelinesWithoutTimeAfter` panics with the nil pointer dereference.
   - `go build`, `go vet` and `golangci-lint run ./plugins/circleci/...`: 
clean, and `gofmt` is clean on the changed files. The circleci e2e tests need 
`E2E_DB_URL`, which I didn't run locally; they cover the extractors and 
converters, not the collectors.
   - Incremental runs are unchanged: the collector framework still stops at 
`createdAfter` through `GetCreated`.
   - No open PR or issue touches the circleci pipeline collector.
   - Suggested label: `pr-type/bug-fix`.
   - AI assistance disclosure: this change was prepared with the help of Claude 
Code (Claude Opus 5.5), and I reviewed the diff. The commit carries a 
`Generated-by:` trailer per the ASF generative tooling guidance.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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