Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(ci): harden bot-comment resolver workflow (#65849)

Raúl Negrón-Otero1feeea6bf11a
diff --git a/.github/workflows/pr-resolve-outdated-bot-comments.yml b/.github/workflows/pr-resolve-outdated-bot-comments.yml
index 02e42679cd14..2452f7ab85b9 100644
--- a/.github/workflows/pr-resolve-outdated-bot-comments.yml
+++ b/.github/workflows/pr-resolve-outdated-bot-comments.yml
@@ -7,6 +7,10 @@ on:
permissions:
contents: read
+concurrency:
+ group: resolve-bot-comments-${{ github.event.pull_request.number }}
+ cancel-in-progress: true
+
jobs:
resolve-outdated:
name: Resolve outdated bot review comments
@@ -27,57 +31,61 @@ jobs:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
+ BOTS: copilot-pull-request-reviewer greptile-apps chatgpt-codex-connector graphite-app cursor claude claude-code-action claude-review
run: |
- BOTS="copilot-pull-request-reviewer greptile-apps chatgpt-codex-connector graphite-app cursor claude claude-code-action claude-review"
+ set -euo pipefail
OWNER="${REPO%/*}"
REPO_NAME="${REPO#*/}"
- THREADS=$(gh api graphql -f query='
- query($owner: String!, $repo: String!, $pr: Int!) {
- repository(owner: $owner, name: $repo) {
- pullRequest(number: $pr) {
- reviewThreads(first: 100) {
- pageInfo { hasNextPage }
- nodes {
- id
- isOutdated
- isResolved
- comments(first: 2) {
- totalCount
+ # Collect every outdated, unresolved, single-comment thread authored by a known bot.
+ # gh --paginate follows the GraphQL cursor (needs the $endCursor variable + pageInfo),
+ # so PRs with more than 100 review threads are fully covered. Best-effort: a fetch or
+ # parse error logs a warning and exits cleanly (pipefail surfaces it; the check stays green).
+ ids=$(gh api graphql --paginate \
+ -f query='
+ query($owner: String!, $repo: String!, $pr: Int!, $endCursor: String) {
+ repository(owner: $owner, name: $repo) {
+ pullRequest(number: $pr) {
+ reviewThreads(first: 100, after: $endCursor) {
+ pageInfo { hasNextPage endCursor }
nodes {
- author { login }
+ id
+ isOutdated
+ isResolved
+ comments(first: 1) {
+ totalCount
+ nodes { author { login } }
+ }
}
}
}
}
- }
- }
- }' -f owner="$OWNER" -f repo="$REPO_NAME" -F pr="$PR_NUMBER")
-
- HAS_NEXT=$(echo "$THREADS" | jq -r '.data.repository.pullRequest.reviewThreads.pageInfo.hasNextPage')
- if [ "$HAS_NEXT" = "true" ]; then
- echo "WARNING: more than 100 review threads found; some outdated bot threads may not be resolved"
- fi
-
- THREAD_IDS=$(echo "$THREADS" | jq -r --arg bots "$BOTS" '
- .data.repository.pullRequest.reviewThreads.nodes[]
- | select(.isOutdated == true and .isResolved == false and .comments.totalCount == 1)
- | select(.comments.nodes[0].author.login as $author | ($bots | split(" ") | any(. == $author)))
- | .id
- ')
+ }' -f owner="$OWNER" -f repo="$REPO_NAME" -F pr="$PR_NUMBER" \
+ | jq -r --arg bots "$BOTS" '
+ .data.repository.pullRequest.reviewThreads.nodes[]
+ | select(.isOutdated == true and .isResolved == false and .comments.totalCount == 1)
+ | select(.comments.nodes[0].author.login as $author | ($bots | split(" ") | any(. == $author)))
+ | .id') || {
+ echo "::warning::failed to fetch or parse review threads; skipping"
+ exit 0
+ }
- if [ -z "$THREAD_IDS" ]; then
+ if [ -z "$ids" ]; then
echo "No outdated bot threads to resolve"
exit 0
fi
- echo "$THREAD_IDS" | while read -r thread_id; do
+ mapfile -t thread_ids <<< "$ids"
+ echo "Resolving ${#thread_ids[@]} outdated bot thread(s)"
+
+ # Resolve best-effort: a single failed mutation must not skip the remaining threads.
+ for thread_id in "${thread_ids[@]}"; do
echo "Resolving thread $thread_id"
gh api graphql -f query='
mutation($id: ID!) {
resolveReviewThread(input: { threadId: $id }) {
thread { isResolved }
}
- }' -f id="$thread_id"
+ }' -f id="$thread_id" || echo "::warning::failed to resolve thread $thread_id"
done