Skip to content

revert GitHub comment workaround#2511

Merged
theakshaypant merged 2 commits intotektoncd:mainfrom
chmouel:srvkp-10938-revert-github-comment-workaround
Mar 2, 2026
Merged

revert GitHub comment workaround#2511
theakshaypant merged 2 commits intotektoncd:mainfrom
chmouel:srvkp-10938-revert-github-comment-workaround

Conversation

@chmouel
Copy link
Copy Markdown
Member

@chmouel chmouel commented Feb 26, 2026

Remove the dedup workaround (jitter, post-create reconciliation, ensureSingleMarkerComment) and replace it with targeted debug enhancements that improve diagnostics without changing behavior:

  • Add githubRequestID() helper to extract X-GitHub-Request-Id from API responses for server-side correlation with GitHub support
  • Add bodyHash() helper (8-char SHA-256) to fingerprint comment bodies at create/edit time for duplicate body detection
  • Log pagination warning when listCommentsByMarker fetches exactly 100 comments (PerPage limit), indicating potential missed matches
  • Log "no_marker" phase when updateMarker is empty so unprotected comment creates are visible in the trace system
  • Add github_request_id to profiler logAPICall for all API calls
  • Simplify CreateComment to edit first matching comment or create new, removing the jitter and post-create dedup logic

Jira: https://issues.redhat.com/browse/SRVKP-10938

📝 Description of the Change

This PR removes the complex dedup workaround in the GitHub provider that used jitter and post-create reconciliation to avoid duplicate comments. It replaces this with cleaner, debug-focused enhancements that improve diagnostics without changing behavior. The changes include new helper functions for extracting GitHub request IDs and fingerprinting comment bodies, enhanced logging for pagination and unprotected comment creation, and simplified CreateComment logic that edits existing comments when possible.

👨🏻‍ Linked Jira

https://issues.redhat.com/browse/SRVKP-10938

🔗 Linked GitHub Issue

🚀 Type of Change

  • 🐛 Bug fix (fix:)
  • ✨ New feature (feat:)
  • 💥 Breaking change (feat!:, fix!:)
  • 📚 Documentation update (docs:)
  • ⚙️ Chore (chore:)
  • 💅 Refactor (refactor:)
  • 🔧 Enhancement (enhance:)
  • 📦 Dependency update (deps:)

🧪 Testing Strategy

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

🤖 AI Assistance

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

If you have used AI assistance, please provide the following details:

Which LLM was used?

  • GitHub Copilot
  • ChatGPT (OpenAI)
  • Claude (Anthropic)
  • Cursor
  • Gemini (Google)
  • Other: ____________

Extent of AI Assistance:

  • Documentation and research only
  • Unit tests or E2E tests only
  • Code generation (parts of the code)
  • Full code generation (most of the PR)
  • PR description and comments
  • Commit message(s)

Important

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: Gemini gemini@google.com
Co-authored-by: ChatGPT noreply@chatgpt.com
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: Cursor noreply@cursor.com
Co-authored-by: Copilot Copilot@users.noreply.github.com

**💡You can use the script ./hack/add-llm-coauthor.sh to automatically add
these co-author trailers to your commits.

✅ 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

Copilot AI review requested due to automatic review settings February 26, 2026 10:59
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @chmouel, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the GitHub comment handling mechanism by removing a previously implemented, complex deduplication workaround. The change simplifies the comment creation and update flow, replacing the old logic with targeted diagnostic enhancements. This improves the clarity of comment operations and provides better traceability for API calls without altering the intended behavior of ensuring a single, up-to-date marker comment.

Highlights

  • Removed Comment Deduplication Workarounds: The complex logic involving jitter, post-create reconciliation, and the ensureSingleMarkerComment function, which aimed to deduplicate GitHub comments, has been entirely removed.
  • Enhanced Debugging and Diagnostics: New helper functions githubRequestID() and bodyHash() were introduced to extract GitHub request IDs from API responses and fingerprint comment bodies, respectively, improving server-side correlation and duplicate body detection.
  • Improved Comment Listing Visibility: A pagination warning is now logged when listCommentsByMarker fetches exactly 100 comments, indicating a potential for missed matches beyond the first page. Additionally, a 'no_marker' phase is logged when updateMarker is empty, making unprotected comment creations visible in the trace system.
  • Simplified Comment Creation Logic: The CreateComment function has been streamlined to first attempt to edit an existing matching comment, and if none is found, it proceeds to create a new one, eliminating the previous jitter and post-create deduplication steps.
  • Centralized API Request ID Logging: The github_request_id is now included in the profiler.logAPICall for all API calls, providing a consistent way to trace GitHub API interactions.
Changelog
  • pkg/provider/github/github.go
    • Added githubRequestID helper function to extract X-GitHub-Request-Id from API responses.
    • Added bodyHash helper function to generate an 8-character SHA-256 fingerprint of comment bodies.
    • Introduced logging for pagination warnings in listCommentsByMarker when 100 comments are fetched.
    • Removed the ensureSingleMarkerComment function and its associated deduplication logic.
    • Refactored CreateComment to simplify its flow: it now edits the first matching comment or creates a new one, removing jitter and post-create reconciliation.
    • Added github_request_id and body_hash to debug logs within CreateComment.
  • pkg/provider/github/github_test.go
    • Removed test cases related to the old deduplication logic, specifically 'deduplicates existing marker comments' and 'deduplicates post-create marker comments'.
    • Updated TestCreateCommentDedupLogging to reflect the new simplified comment creation/editing flow and expected log phases.
    • Added a new test case to TestCreateCommentDedupLogging for logging the 'no_marker' phase when updateMarker is empty.
    • Modified test setup to pass updateMarker dynamically to CreateComment.
    • Adjusted assertions for expected and unexpected log phases to match the revised logic, including new body_hash fields.
  • pkg/provider/github/profiler.go
    • Included github_request_id from the GitHub response header in the logAPICall function's log fields.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@pipelines-as-code
Copy link
Copy Markdown

pipelines-as-code bot commented Feb 26, 2026

🔍 PR Lint Feedback

Note: This automated check helps ensure your PR follows our contribution guidelines.

⚠️ Items that need attention:

📝 PR title format

Current title: revert GitHub comment workaround

Expected format <type>(<scope>): <subject> with <type> one of [build, chore, ci, docs, deps, enhance, feat, dnm, fix, perf, refactor, release, revert, style, test].

Expected pattern: <type>(<scope>): <subject>
Allowed types: build, chore, ci, docs, deps, enhance, feat, dnm, fix, perf, refactor, release, revert, style, test

Examples:

  • fix(controller): ensure reconciler handles nil spec
  • docs: update contributing guide with lint instructions

🤖 AI attribution

The following commits lack an explicit AI attribution footer:

  • 0df2469 chore: remove GitHub comment dedup workaround

If no AI assistance was used for a commit, you can ignore this warning.
Otherwise add an Assisted-by: or Co-authored-by: footer referencing the AI used.


ℹ️ Next Steps

  • Review and address the items above
  • Push new commits to update this PR
  • This comment will be automatically updated when issues are resolved
🔧 Admin Tools (click to expand)

Automated Issue/Ticket Creation:

  • /issue-create - Generate a GitHub issue from this PR content using AI
  • /jira-create - Create a SRVKP Jira ticket from this PR content using AI

⚠️ Important: Always review and edit generated content before finalizing tickets/issues.
The AI-generated content should be used as a starting point and may need adjustments.

These commands are available to maintainers and will post the generated content as PR comments for review.

🤖 This feedback was generated automatically by the PR CI system

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reverts the GitHub comment deduplication workaround and replaces it with targeted debug enhancements for better diagnostics. The change simplifies the comment creation flow by removing the jitter-based timing workaround, post-create reconciliation logic, and the ensureSingleMarkerComment function, while adding diagnostic helpers (githubRequestID, bodyHash) and improved logging to support troubleshooting duplicate comment issues.

Changes:

  • Removed deduplication workaround including jitter delays, post-create reconciliation, and ensureSingleMarkerComment function
  • Added diagnostic helpers (githubRequestID(), bodyHash()) for improved observability
  • Simplified CreateComment to edit first matching comment or create new without dedup logic

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pkg/provider/github/profiler.go Added github_request_id field to API call logs for server-side correlation
pkg/provider/github/github.go Removed deduplication logic and added diagnostic helpers; simplified CreateComment flow
pkg/provider/github/github_test.go Updated tests to reflect simplified flow and added test for no_marker phase logging

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request reverts a workaround for GitHub comment deduplication, simplifying the logic to "update first or create new". It also enhances diagnostic logging by adding GitHub request IDs and comment body fingerprints to logs. The changes are well-reflected in the updated tests. I've found a critical issue that could lead to a panic in the logging code and a medium-severity issue regarding a hardcoded value that should be a configurable property.

@chmouel
Copy link
Copy Markdown
Member Author

chmouel commented Feb 26, 2026

the e2e issue:

Please check in your pipeline what can be changing the following files:
?? startpaac/

2026/02/26 11:02:56 Building github.com/openshift-pipelines/pipelines-as-code/cmd/pipelines-as-code-watcher for linux/amd64
2026/02/26 11:03:56 Publishing registry.paac-127-0-0-1.nip.io/nonoai:latest
2026/02/26 11:03:57 pushed blob: sha256:e33bce57de289fffd2380f73997dfb7e1ec193877904bed99f28c715d071fdc4
2026/02/26 11:03:57 pushed blob: sha256:1c56d6035a42c0a75d79cc88acf6c9d4104343639f19b8262b520c449731445d
2026/02/26 11:03:57 pushed blob: sha256:b6824ed73363f94b3b2b44084c51c31bc32af77a96861d49e16f91e3ab6bed71
2026/02/26 11:03:57 pushed blob: sha256:473d8557b1b27974f7dc7c4b4e1a209df0e27e8cae1e3e33b7bb45c969b6fc7e
2026/02/26 11:03:57 pushed blob: sha256:7c12895b777bcaa8ccae0605b4de635b68fc32d60fa08f421dc3818bf55ee212
2026/02/26 11:03:57 pushed blob: sha256:33e068de264953dfdc9f9ada207e76b61159721fd64a4820b320d05133a55fb8
2026/02/26 11:03:57 pushed blob: sha256:5664b15f108bf9436ce3312090a767300800edbbfd4511aa1a6d64357024d5dd
2026/02/26 11:03:57 pushed blob: sha256:27be814a09ebd97fac6fb7b82d19f117185e90601009df3fbab6f442f85cd6b3
2026/02/26 11:03:57 pushed blob: sha256:4aa0ea1413d37a58615488592a0b827ea4b2e48fa5a77cf707d0e35f025e613f
2026/02/26 11:03:57 pushed blob: sha256:9ef7d74bdfdf3c517b28bd694a9159e94e5f53ff1ca87b39f8ca1ac0be2ed317
2026/02/26 11:03:57 pushed blob: sha256:9112d77ee5b16873acaa186b816c3c61f5f8eba40730e729e9614a27f40211e0
2026/02/26 11:03:57 pushed blob: sha256:250c06f7c38e52dc77e5c7586c3e40280dc7ff9bb9007c396e06d96736cf8542
2026/02/26 11:03:57 pushed blob: sha256:8afcf1231e46a98da405f48aa808bc379901638dbd6d31ba591eb993bd9f2f44
2026/02/26 11:03:58 pushed blob: sha256:a4ba90834fb4abf3d80bbdaaaef36560ab1bb682f5279d44114d768e119639b9
2026/02/26 11:03:58 pushed blob: sha256:df368711b36276ed02b2040d3e3296b919042d2a05a2bbe9f758e708436c12cf
2026/02/26 11:03:58 pushed blob: sha256:a1357c4884d2d0537eedb5c26b622ea8afd0f6707446445b6d82f8918388dff2
2026/02/26 11:03:58 pushed blob: sha256:83f8d4690e1f293d0438aef7d1075e590ce77fdec97bb4d90b1d227aeba343fd
2026/02/26 11:03:58 registry.paac-127-0-0-1.nip.io/nonoai:latest: digest: sha256:9b49ddb8bb81cd39c6933dc4526f5b5eb23c48c6cfffb58b6fa27abbada3c98d size: 2944
2026/02/26 11:03:58 Published registry.paac-127-0-0-1.nip.io/nonoai@sha256:9b49ddb8bb81cd39c6933dc4526f5b5eb23c48c6cfffb58b6fa27abbada3c98d
2026/02/26 11:06:06 Publishing registry.paac-127-0-0-1.nip.io/pipelines-as-code-webhook:latest
Error: error processing import paths in "config/600-webhook.yaml": error resolving image references: Head "https://registry.paac-127-0-0-1.nip.io/v2/pipelines-as-code-webhook/manifests/latest": stopped after 10 redirects
Error: Process completed with exit code 1.

trying to fix it in pipelines-as-code/startpaac#11

Remove the dedup workaround (jitter, post-create reconciliation,
ensureSingleMarkerComment) and replace it with targeted debug
enhancements that improve diagnostics without changing behavior:

- Add githubRequestID() helper to extract X-GitHub-Request-Id from
  API responses for server-side correlation with GitHub support
- Add bodyHash() helper (8-char SHA-256) to fingerprint comment
  bodies at create/edit time for duplicate body detection
- Log pagination warning when listCommentsByMarker fetches exactly
  100 comments (PerPage limit), indicating potential missed matches
- Log "no_marker" phase when updateMarker is empty so unprotected
  comment creates are visible in the trace system
- Add github_request_id to profiler logAPICall for all API calls
- Simplify CreateComment to edit first matching comment or create
  new, removing the jitter and post-create dedup logic

Jira: https://issues.redhat.com/browse/SRVKP-10938
Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
@chmouel chmouel force-pushed the srvkp-10938-revert-github-comment-workaround branch from a73850f to 0df2469 Compare February 26, 2026 14:53
@pipelines-as-code pipelines-as-code bot added the enhancement New feature or request label Feb 26, 2026
@theakshaypant theakshaypant merged commit 8a2e0e4 into tektoncd:main Mar 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants