Azure / Azure/azure-sdk-tools

[APIView] One-time cleanup: remove stale pending automatic revisions accumulated by cleanup bug

Open
#15,239 3 comments 0 reactions 1 assignee Claimed by @tjprescott View on GitHub
APIView bug
Dominant language
C#
Stars
135
Forks
260
Avg merge
3d 1h
Merged PRs (30d)
143

Description

Two bugs in `CreateAutomaticRevisionAsync`

1. The cleanup loop exited early on a content-hash match, leaving older pending revisions behind.
2. When a stale candidate didn't match incoming content, it was not deleted before the new revision was created.

As a result, production reviews may have accumulated multiple stale pending automatic revisions that should have been deleted.

### Task

Write a one-time migration/backfill job that applies the same cleanup invariant retroactively to all existing reviews:

- For each review, fetch all automatic revisions ordered newest → oldest
- Walk the list and keep only the newest unprotected pending revision since the last approval/released/commented anchor
- Soft-delete all older unprotected pending revisions between the newest pending and the anchor
- Respect version scoping — only clean up revisions belonging to the same `APIVersionId`
- Respect hard-stop boundaries — do not touch any revision that is approved, released, or has comments

### Acceptance Criteria

- [ ] All reviews have at most one pending automatic revision per version since the last approval anchor
- [ ] No approved, released, or commented revisions are touched
- [ ] The job is idempotent — safe to run multiple times
- [ ] The job logs how many revisions were deleted per review for auditability

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.