Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/test-bad-changeset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": minor
---

# fix bug
Copy link
Contributor

Choose a reason for hiding this comment

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

🔴 Changeset uses h1 header, violating mandatory changeset formatting rule

.changeset/test-bad-changeset.md:5 uses # fix bug — an h1 (#) header — in the changeset description. AGENTS.md explicitly states under Changeset Rules: "No h1/h2/h3 headers in changeset descriptions (changelog uses h3)". This is also documented in .changeset/README.md:84: "Changeset descriptions must NOT use h1 (#), h2 (##), or h3 (###) headers." If merged, this h1 would break the generated changelog formatting since the changelog already uses h3 for section headers.

Suggested change
# fix bug
fix bug
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


update stuff
Comment on lines +1 to +7
Copy link
Contributor

Choose a reason for hiding this comment

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

🔴 Test changeset files would trigger unintended wrangler releases if merged

Both .changeset/test-bad-changeset.md ("wrangler": minor) and .changeset/test-good-changeset.md ("wrangler": patch) are test fixtures for workflow validation (commit message says "TEMPORARY") but are included in the PR diff. If merged, they would cause real wrangler version bumps with fake changelog entries. Per AGENTS.md, "CI/workflow changes that don't affect package behavior" do not require changesets, and per .changeset/README.md, changeset descriptions must correspond to actual code changes. test-good-changeset.md describes a fictional bug fix that doesn't exist in this PR, and test-bad-changeset.md uses a vague "fix bug" / "update stuff" description that .changeset/README.md:75 explicitly calls out as a bad example.

Prompt for agents
Delete both .changeset/test-bad-changeset.md and .changeset/test-good-changeset.md before merging. These are temporary test fixtures that would cause unintended wrangler version bumps (a minor and a patch release) with fake changelog entries if they land in main.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

7 changes: 7 additions & 0 deletions .changeset/test-good-changeset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

Fix `wrangler dev` failing when configuration file contains trailing commas

Previously, `wrangler dev` would crash with a JSON parse error if `wrangler.json` contained trailing commas in arrays or objects. Since JSONC supports trailing commas, this is now handled correctly by using a JSONC-aware parser.
98 changes: 88 additions & 10 deletions .github/workflows/changeset-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,38 @@ jobs:
# Recover deleted files so Claude can read them (needed for Version Packages PRs)
recover_deleted_files: ${{ github.event.pull_request.title == 'Version Packages' }}

- name: Clean up prior changeset reviews
if: github.event.pull_request.title == 'Version Packages' || steps.changed-changesets.outputs.added_files_count > 0
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
COMMENTS=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/comments" --paginate | jq -s 'add')

# Delete sticky OK comments (identified by embedded HTML marker)
echo "$COMMENTS" | jq -r '.[] | select(.body | contains("<!-- changeset-review -->")) | .id' | while read -r COMMENT_ID; do
echo "Deleting sticky OK comment ${COMMENT_ID}"
gh api "repos/${REPO}/issues/comments/${COMMENT_ID}" -X DELETE || true
done

# Find marker comments from prior issue-review runs, delete the associated review comments and the marker
echo "$COMMENTS" | jq -c '.[] | select(.body | contains("<!-- changeset-review-marker"))' | while read -r ITEM; do
COMMENT_ID=$(echo "$ITEM" | jq -r '.id')
BODY=$(echo "$ITEM" | jq -r '.body')
REVIEW_ID=$(echo "$BODY" | grep -oP '(?<=review-id:)\d+')
if [ -n "$REVIEW_ID" ]; then
echo "Deleting comments on prior review ${REVIEW_ID}"
# Submitted reviews cannot be deleted via the API; delete each review comment individually instead
gh api "repos/${REPO}/pulls/${PR_NUMBER}/reviews/${REVIEW_ID}/comments" \
| jq -r '.[].id' | while read -r RC_ID; do
gh api "repos/${REPO}/pulls/comments/${RC_ID}" -X DELETE || true
done
Comment on lines +70 to +73
Copy link
Contributor

Choose a reason for hiding this comment

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

🔴 Missing error handling on review-comments listing API call can permanently block the workflow

At .github/workflows/changeset-review.yml:70, the gh api call to list a prior review's comments has no || true error handling. GitHub Actions runs bash with set -eo pipefail, so if the referenced review no longer exists (e.g. manually deleted through the UI while the marker comment remains), this call returns a 404 and the entire cleanup step fails. Since cleanup runs before review posting, this blocks the new review from being created. Worse, the orphaned marker comment persists, so every subsequent workflow run will hit the same failure until the marker is manually removed. The individual DELETE calls on line 72 correctly use || true, but the LIST call that feeds them does not.

Problematic code
gh api "repos/${REPO}/pulls/${PR_NUMBER}/reviews/${REVIEW_ID}/comments" \
  | jq -r '.[].id' | while read -r RC_ID; do
    gh api "repos/${REPO}/pulls/comments/${RC_ID}" -X DELETE || true
  done
Suggested change
gh api "repos/${REPO}/pulls/${PR_NUMBER}/reviews/${REVIEW_ID}/comments" \
| jq -r '.[].id' | while read -r RC_ID; do
gh api "repos/${REPO}/pulls/comments/${RC_ID}" -X DELETE || true
done
gh api "repos/${REPO}/pulls/${PR_NUMBER}/reviews/${REVIEW_ID}/comments" 2>/dev/null
| jq -r '.[].id' | while read -r RC_ID; do
gh api "repos/${REPO}/pulls/comments/${RC_ID}" -X DELETE || true
done || true
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

fi
echo "Deleting marker comment ${COMMENT_ID}"
gh api "repos/${REPO}/issues/comments/${COMMENT_ID}" -X DELETE || true
done
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Submitted reviews cannot be deleted via the REST API.

The GitHub API DELETE /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id} only works on pending (unsubmitted) reviews. The workflow creates reviews with event: COMMENT (line 142), which submits them immediately. This means the DELETE call here will always fail with a 422, and the || true silently swallows the error. Stale review threads will accumulate across pushes — the exact problem the cleanup step is meant to prevent.

To actually remove old reviews, you have two options:

  1. Dismiss the review via PUT .../reviews/{id}/dismissals — this doesn't delete the comments but marks the review as dismissed.
  2. Delete each review comment individually — list comments with GET .../reviews/{id}/comments, then DELETE .../pulls/comments/{comment_id} for each one. This fully removes the inline threads.

Option 2 is probably what you want since the goal is to remove stale resolvable threads.

Comment on lines +47 to +77
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 Cleanup step deletes old review comments before new review is generated, causing review loss on OpenCode failure

The "Clean up prior changeset reviews" step (Step 3) runs before the "Review Changesets with OpenCode" step (Step 4). If OpenCode fails (e.g. API timeout, bad response, rate limit), Step 4 fails, the job aborts, and "Post review results" (Step 5) never runs. At this point, all prior review comments and marker comments have already been deleted by Step 3, leaving the PR with no changeset review feedback at all. The cleanup should occur only after the new review JSON is successfully generated, or at least only after verifying the new review was posted.

Prompt for agents
In .github/workflows/changeset-review.yml, move the "Clean up prior changeset reviews" step (currently Step 3, lines 47-77) to run AFTER the "Review Changesets with OpenCode" step (Step 4) but BEFORE the "Post review results" step (Step 5). This ensures old reviews are only deleted once we have a new changeset-review.json ready to post. Alternatively, split the cleanup into two parts: one in the "Post review results" step (run cleanup just before posting), so that old reviews are only deleted when new ones are guaranteed to replace them.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


- name: Review Changesets with OpenCode
id: opencode-review
# Run for Version Packages PRs (which delete changesets) or regular PRs with new changesets
Expand All @@ -69,20 +101,66 @@ jobs:
5. **Dependabot**: Do not validate dependency update changesets for create-cloudflare
6. **Experimental features**: Changesets for experimental features should include note on how users can opt in.

If all changesets pass, just output \"✅ All changesets look good\" - no need for a detailed checklist.
Write your review as JSON to \`changeset-review.json\` in this exact format (no other output):
{
\"status\": \"ok\",
\"summary\": \"✅ All changesets look good.\",
\"files\": []
}
or when there are issues:
{
\"status\": \"issues\",
\"summary\": \"⚠️ Issues found in N of M changesets.\",
\"files\": [
{
\"path\": \".changeset/foo.md\",
\"status\": \"issues\",
\"comment\": \"<specific problems with this file>\"
}
]
}

Do not review other files, only the changesets. This is specifically a changeset review action.
Only include files in the array when they have status \"issues\".
The top-level status must be \"issues\" if ANY file has issues, otherwise \"ok\".
Do not review other files, only the changesets. This is specifically a changeset review action."

If there are issues, output \"⚠️ Issues found\" followed by the specific problems.
- name: Post review results
if: steps.opencode-review.outcome == 'success'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
STATUS=$(jq -r '.status' changeset-review.json)
SUMMARY=$(jq -r '.summary' changeset-review.json)

Write your review to changeset-review.md."
if [ "$STATUS" = "issues" ]; then
# Build the request body: file-level comments (subject_type: "file") for each problematic changeset
REQUEST_BODY=$(jq -n \
--arg commit_id "$HEAD_SHA" \
--argjson comments "$(jq '[.files[] | select(.status == "issues") | {path: .path, subject_type: "file", body: .comment}]' changeset-review.json)" \
'{commit_id: $commit_id, event: "COMMENT", body: "", comments: $comments}')

- name: Post review comment
if: steps.opencode-review.outcome == 'success'
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
with:
header: changeset-review
path: changeset-review.md
# Post a pull request review with inline file-level comments
REVIEW_RESPONSE=$(echo "$REQUEST_BODY" | gh api "repos/${REPO}/pulls/${PR_NUMBER}/reviews" \
-X POST \
--input -)

REVIEW_ID=$(echo "$REVIEW_RESPONSE" | jq -r '.id')
echo "Posted review ${REVIEW_ID}"

# Post a hidden marker comment so the next run can find and delete this review
gh api "repos/${REPO}/issues/${PR_NUMBER}/comments" \
-X POST \
-f "body=<!-- changeset-review-marker review-id:${REVIEW_ID} -->"
else
# Post a normal (non-resolvable) PR comment with a hidden marker for cleanup
gh api "repos/${REPO}/issues/${PR_NUMBER}/comments" \
-X POST \
-f "body=<!-- changeset-review -->
${SUMMARY}"
fi

- name: Skip notice
if: github.event.pull_request.title != 'Version Packages' && steps.changed-changesets.outputs.added_files_count == 0
Expand Down
Loading