Skip to content

t2793: fix pulse external-contributor comment spam — use REST API for labels#2794

Merged
alex-solovyev merged 1 commit intomainfrom
bugfix/t2793-pulse-label-rest-api
Mar 4, 2026
Merged

t2793: fix pulse external-contributor comment spam — use REST API for labels#2794
alex-solovyev merged 1 commit intomainfrom
bugfix/t2793-pulse-label-rest-api

Conversation

@alex-solovyev
Copy link
Collaborator

@alex-solovyev alex-solovyev commented Mar 4, 2026

Summary

  • Replace gh pr edit --add-label with gh api repos/<slug>/issues/<number>/labels -X POST REST endpoint in two locations in pulse.md
  • The GraphQL-backed gh pr edit fails with "Projects (classic) is being deprecated" warning (exit 1), preventing label application and breaking the idempotency guard
  • This caused 17+ duplicate "external contributor" comments on PR feat: add memory pressure monitor with launchd integration #2792 because the label was never applied and the guard never triggered

Changes

.agents/scripts/commands/pulse.md — two one-line replacements:

  1. Line 84 (external-contributor gate): gh pr edit --add-label "external-contributor"gh api "repos/<slug>/issues/<number>/labels" -X POST -f 'labels[]=external-contributor'
  2. Line 246 (orphaned PR scanner): gh pr edit --add-label "status:orphaned"gh api "repos/<slug>/issues/<number>/labels" -X POST -f 'labels[]=status:orphaned'

Both retain the 2>/dev/null || true error suppression for resilience.

Why REST API

The GitHub REST endpoint POST /repos/{owner}/{repo}/issues/{number}/labels is not affected by the GraphQL Projects deprecation. It returns a clean 200 and applies the label reliably. This was already validated manually on PR #2792.

Closes #2793

Summary by CodeRabbit

  • Chores
    • Updated the PR labeling process to use an alternative method for improved consistency.

gh pr edit --add-label fails with GraphQL Projects deprecation warning
(exit 1), preventing the external-contributor label from being applied.
This broke the idempotency guard, causing duplicate comments on every
pulse cycle (17+ on PR #2792).

Replace both instances (external-contributor gate and orphaned PR
scanner) with gh api repos/<slug>/issues/<number>/labels REST endpoint
which works correctly.

Closes #2793
@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Mar 4, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 updates the pulse.md script to use the GitHub REST API for applying labels instead of the gh pr edit command. This change resolves an issue where a deprecated GraphQL endpoint caused label application to fail, leading to repetitive "external contributor" comments on pull requests and breaking the script's idempotency guard. The new approach ensures labels are applied reliably and prevents future comment spam.

Highlights

  • API Command Update: Replaced gh pr edit --add-label with gh api calls for applying labels in pulse.md.
  • Issue Resolution: Addressed the "Projects (classic) is being deprecated" error that caused gh pr edit to fail, leading to duplicate "external contributor" comments.
Changelog
  • .agents/scripts/commands/pulse.md
    • Replaced gh pr edit --add-label "external-contributor" with gh api "repos/<slug>/issues/<number>/labels" -X POST -f 'labels[]=external-contributor'.
    • Replaced gh pr edit --add-label "status:orphaned" with gh api "repos/<slug>/issues/<number>/labels" -X POST -f 'labels[]=status:orphaned'.
Activity
  • No human activity (comments, reviews, etc.) has been recorded on this pull request yet.
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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 72e40ca and 3f06500.

📒 Files selected for processing (1)
  • .agents/scripts/commands/pulse.md

Walkthrough

This change replaces two gh pr edit --add-label commands with equivalent REST API calls using gh api in the pulse script. The switch addresses a GraphQL deprecation issue causing label application failures and resulting idempotency guard bypasses.

Changes

Cohort / File(s) Summary
Pulse Script Label Handling
.agents/scripts/commands/pulse.md
Replaced two gh pr edit --add-label commands (external-contributor and status:orphaned labels) with REST API POST calls to repos/<slug>/issues/<number>/labels. Maintains identical control flow and error handling; resolves GraphQL-backed command failures causing idempotency guard bypasses.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • PR #1375: Touches Pulse labeling flow by restoring ALL_STATUS_LABELS used in label reconciliation alongside this PR's label application changes.
  • PR #2740: Modifies pulse's external-contributor label handling with review gates, directly related to the external-contributor label REST API switch in this PR.

Poem

REST API to the rescue, GraphQL deprecated, 🚀
No more spam comments—idempotency regained! ✨
One command swapped, the guard now stands true.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing gh pr edit with REST API calls to fix label application failures that cause comment spam.
Linked Issues check ✅ Passed The PR directly addresses issue #2793 by replacing gh pr edit --add-label with REST API calls at both required locations in pulse.md, fixing the label application failures.
Out of Scope Changes check ✅ Passed All changes are scoped to the pulse.md file and directly address the stated objectives of replacing two gh pr edit commands with REST API equivalents.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/t2793-pulse-label-rest-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 113 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Wed Mar 4 00:25:22 UTC 2026: Code review monitoring started
Wed Mar 4 00:25:22 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 113

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 113
  • VULNERABILITIES: 0

Generated on: Wed Mar 4 00:25:25 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link

@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 correctly resolves an issue with comment spam by replacing a failing gh pr edit command with a direct gh api call. This is a solid fix. However, the implementation retains the use of 2>/dev/null, which suppresses all error output and can make debugging difficult. My review includes suggestions to replace this with the gh api command's --silent flag, which aligns better with general scripting guidelines by hiding successful output while still showing important error messages.

Note: Security Review has been skipped due to the limited scope of the PR.

if ! gh pr view <number> --repo <slug> --json labels --jq '.labels[].name' 2>/dev/null | grep -q '^external-contributor$'; then
gh pr comment <number> --repo <slug> --body "This PR is from an external contributor (@<author>). Auto-merge is disabled for external PRs — a maintainer must review and merge manually."
gh pr edit <number> --repo <slug> --add-label "external-contributor" 2>/dev/null || true
gh api "repos/<slug>/issues/<number>/labels" -X POST -f 'labels[]=external-contributor' 2>/dev/null || true

Choose a reason for hiding this comment

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

medium

Using 2>/dev/null suppresses all error output, which can hide underlying problems with authentication, network, or API changes, making debugging difficult. The project's scripting guidelines recommend avoiding blanket error suppression.

The gh api command includes a --silent flag that suppresses the successful JSON response on stdout without hiding genuine errors on stderr. Adopting this flag would make the command more robust and easier to debug.

Suggested change
gh api "repos/<slug>/issues/<number>/labels" -X POST -f 'labels[]=external-contributor' 2>/dev/null || true
gh api --silent "repos/<slug>/issues/<number>/labels" -X POST -f 'labels[]=external-contributor' || true


```bash
gh pr edit <number> --repo <slug> --add-label "status:orphaned" 2>/dev/null || true
gh api "repos/<slug>/issues/<number>/labels" -X POST -f 'labels[]=status:orphaned' 2>/dev/null || true

Choose a reason for hiding this comment

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

medium

As with the other change, using 2>/dev/null is not ideal as it hides all error messages. To improve debuggability and align with project guidelines, please use the --silent flag to suppress successful output while allowing errors to be reported to stderr.

Suggested change
gh api "repos/<slug>/issues/<number>/labels" -X POST -f 'labels[]=status:orphaned' 2>/dev/null || true
gh api --silent "repos/<slug>/issues/<number>/labels" -X POST -f 'labels[]=status:orphaned' || true

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

@alex-solovyev alex-solovyev merged commit c6185ee into main Mar 4, 2026
31 of 32 checks passed
@alex-solovyev alex-solovyev deleted the bugfix/t2793-pulse-label-rest-api branch March 4, 2026 00:28
alex-solovyev added a commit that referenced this pull request Mar 4, 2026
… function (t1391)

The LLM supervisor kept re-implementing the inline bash idempotency
guard incorrectly on each pulse cycle, causing 15+ duplicate
'external contributor' comments on PR #2792 despite 4 prior fix
attempts (PRs #2794, #2796, #2801, #2803) — all in pulse.md prompt
text.

Root cause: the check is deterministic (one correct answer regardless
of context) but was encoded as prompt guidance that the LLM had to
re-implement each cycle. Per the 'Intelligence Over Determinism'
principle, deterministic logic belongs in the harness, not the prompt.

Changes:
- Add check_external_contributor_pr() to pulse-wrapper.sh: checks
  BOTH label AND comment, captures exit codes separately, fails
  closed on any API error, only posts when confirmed safe
- Add check_permission_failure_pr() companion function for the
  permission API failure case
- Add source guard (BASH_SOURCE check) so pulse-wrapper.sh can be
  sourced for its functions without triggering the full lifecycle
- Update pulse.md to call the helper functions instead of inline bash
- Update Hard Rule 12 to reference the helper functions

Closes #2809
alex-solovyev added a commit that referenced this pull request Mar 4, 2026
… function (t1391) (#2810)

The LLM supervisor kept re-implementing the inline bash idempotency
guard incorrectly on each pulse cycle, causing 15+ duplicate
'external contributor' comments on PR #2792 despite 4 prior fix
attempts (PRs #2794, #2796, #2801, #2803) — all in pulse.md prompt
text.

Root cause: the check is deterministic (one correct answer regardless
of context) but was encoded as prompt guidance that the LLM had to
re-implement each cycle. Per the 'Intelligence Over Determinism'
principle, deterministic logic belongs in the harness, not the prompt.

Changes:
- Add check_external_contributor_pr() to pulse-wrapper.sh: checks
  BOTH label AND comment, captures exit codes separately, fails
  closed on any API error, only posts when confirmed safe
- Add check_permission_failure_pr() companion function for the
  permission API failure case
- Add source guard (BASH_SOURCE check) so pulse-wrapper.sh can be
  sourced for its functions without triggering the full lifecycle
- Update pulse.md to call the helper functions instead of inline bash
- Update Hard Rule 12 to reference the helper functions

Closes #2809
alex-solovyev added a commit that referenced this pull request Mar 4, 2026
Addresses quality-debt review feedback from PR #2794 (Gemini).

2>/dev/null suppresses all stderr, hiding auth, network, and API errors.
gh api --silent only suppresses the successful JSON response body on
stdout while preserving genuine error output on stderr. The || true
already handles non-zero exit codes for resilience.

Three call sites updated:
- pulse.md:279 (orphaned PR labeling)
- pulse-wrapper.sh:660 (external-contributor label re-add)
- pulse-wrapper.sh:671 (external-contributor label on first flag)

Closes #2819
alex-solovyev added a commit that referenced this pull request Mar 4, 2026
)

Addresses quality-debt review feedback from PR #2794 (Gemini).

2>/dev/null suppresses all stderr, hiding auth, network, and API errors.
gh api --silent only suppresses the successful JSON response body on
stdout while preserving genuine error output on stderr. The || true
already handles non-zero exit codes for resilience.

Three call sites updated:
- pulse.md:279 (orphaned PR labeling)
- pulse-wrapper.sh:660 (external-contributor label re-add)
- pulse-wrapper.sh:671 (external-contributor label on first flag)

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

Labels

bug Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: pulse external-contributor comment spam — gh pr edit --add-label fails silently

1 participant