Skip to content

fix(circleci): collect pipelines when the sync policy has no timeAfter - #9368

Open
ShivamSharma43 wants to merge 1 commit into
apache:mainfrom
ShivamSharma43:fix/circleci-nil-time-after
Open

ShivamSharma43 wants to merge 1 commit into
apache:mainfrom
ShivamSharma43:fix/circleci-nil-time-after

Conversation

@ShivamSharma43

Copy link
Copy Markdown
Contributor

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:

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

CollectPipelines dereferenced SyncPolicy().TimeAfter for every pipeline
in the response. TimeAfter is nil for advanced mode blueprints, when the
start date is cleared, and for directrun without timeAfter, so the
response parser panicked and the subtask failed with a nil pointer
dereference.

Move the response parsing into parsePipelines, keep every pipeline when
timeAfter is nil, and check that SyncPolicy() isn't nil before reading
it.

Closes apache#9367

Generated-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Shivam Sharma <192242476+ShivamSharma43@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 10, 2026 17:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][CircleCI] collectPipelines panics with a nil pointer dereference when the sync policy has no timeAfter

2 participants