Skip to content

fix(adapter): eliminate data race on shared event field#2590

Open
chmouel wants to merge 2 commits intotektoncd:mainfrom
chmouel:eliminate-data-race-on-shared-event-field
Open

fix(adapter): eliminate data race on shared event field#2590
chmouel wants to merge 2 commits intotektoncd:mainfrom
chmouel:eliminate-data-race-on-shared-event-field

Conversation

@chmouel
Copy link
Member

@chmouel chmouel commented Mar 18, 2026

📝 Description of the Change

The listener struct had a shared event *info.Event field that was
written to by concurrent HTTP request handlers. When two requests
arrived simultaneously (e.g. a push event and an incoming webhook),
both would write to l.event, causing the push handler to read the
incoming handler's event data. This resulted in the push event being
processed as event_type=incoming, matching the wrong PipelineRun
triggers and creating duplicate PipelineRuns.

Remove event from the listener struct and make it a local variable
per request in handleEvent. Pass it as a parameter to detectIncoming
and processIncoming so each concurrent request operates on its own
isolated event object.

Signed-off-by: Chmouel Boudjnah chmouel@redhat.com
Assisted-by: Claude Opus 4.6 (via Claude Code)

🔗 Linked GitHub Issue

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

AI assistance can be used for various tasks, such as code generation,
documentation, or testing.

Please indicate whether you have used AI assistance
for this PR and provide details if applicable.

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

Important

Slop will be simply rejected, if you are using AI assistance you need to make sure you
understand the code generated and that it meets the project's standards. you
need at least know how to run the code and deploy it (if needed). See
startpaac to make it easy
to deploy and test your code changes.

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Claude noreply@anthropic.com

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

The listener struct had a shared `event *info.Event` field that was
written to by concurrent HTTP request handlers. When two requests
arrived simultaneously (e.g. a push event and an incoming webhook),
both would write to l.event, causing the push handler to read the
incoming handler's event data. This resulted in the push event being
processed as event_type=incoming, matching the wrong PipelineRun
triggers and creating duplicate PipelineRuns.

Remove `event` from the listener struct and make it a local variable
per request in handleEvent. Pass it as a parameter to detectIncoming
and processIncoming so each concurrent request operates on its own
isolated event object.

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
Assisted-by: Claude Opus 4.6 (via Claude Code)
@chmouel
Copy link
Member Author

chmouel commented Mar 18, 2026

@zakisk i think that what you were trying to do last time? this mostly is an issue with incoming webhooks, since we are sharing the info.Event pointer in there, so this PR makes it local, PTAL

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.

1 participant