Skip to content

ci: stop the cleanup on the primary rate limit - #12

Merged
viceice merged 1 commit into
mainfrom
viceice/cleanup-primary-rate-limit
Nov 26, 2026
Merged

viceice merged 1 commit into
mainfrom
viceice/cleanup-primary-rate-limit

Conversation

@viceice

@viceice viceice commented Nov 26, 2026

Copy link
Copy Markdown
Member

Changes

Run 45745323713 started with 4800 requests by /rate_limit, but the installation limit was nearly used by the run before. It then retried 2261 deletes failing with API rate limit exceeded for installation: the error was cut to 300 characters before it was checked, dropping the (HTTP 403) at the end of that long message.

  • the whole error decides, only the log gets the short one
  • any rate limit, primary or secondary, stops the run, the next run continues
  • a rate limit while reading a page stops the run too, instead of failing it after three attempts

Context

  • This closes an existing Issue, Closes: #
  • This doesn't close an Issue, but I accept the risk that this PR may be closed if maintainers disagree with its opening or implementation

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Use of AI in replying to PR comments

Who answers review comments:

  • @viceice will read and reply directly.
  • An agent will draft replies and @username will read them before they are posted.
  • An agent will draft replies and reply autonomously.
  • Nobody has explicitly committed to replying.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified tests

Run against a fake gh with GitHub's full primary rate limit message: rate limited deletes stop the run after the first one (4 requests, was 2261 retries), a rate limited page read stops it too, a 403 without rate limit still fails it, a broken response is still left for the next run.

Drafted by Claude Code (Claude Opus 5.5, medium effort) on behalf of @viceice.


Generated by Claude Code

A run started with 4800 requests by /rate_limit, but the installation's
limit was nearly used by the run before; it then retried 2261 deletes
that failed with `API rate limit exceeded for installation`. The error
was cut to 300 characters before it was checked, which dropped the
`(HTTP 403)` at the end of that long message, so it counted as transient.

- the whole error decides, only the log gets the short one
- any rate limit, primary or secondary, stops the run
- a rate limit while reading a page stops the run too, instead of failing
  it after three attempts

Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io>
Claude-Session: https://claude.ai/code/session_01QDtJ4KzQDumLuVTjbJNkWv
@qodo-code-review

qodo-code-review Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Stop cleanup when GitHub hits a primary or secondary rate limit

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Detect rate limits from full API errors while keeping logged messages short.
• Stop on rate-limited page reads or deletes so the next run can continue.
• Preserve failures for unrelated client errors and defer transient delete errors.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The workflow invokes this script to enumerate and delete old versions from the configured container packages; the changed branches only alter this cleanup outcome, not build or cache-consumption behavior.
Behavioral complexity 🟡 Medium 🧩 Interacting branches

  • Before, truncated error text determined 404, rate-limit, and retry classification, and all read failures followed the generic failure path.
  • After, full normalized messages drive separate rate-limit stop, gone, retry, and failure states, while read rate limits return a distinct status to the package loop.
  • New correctness condition: classification must remain consistent across read errors, delete errors, follow-up checks, budget accounting, and next-run retry behavior.
  • The branch structure is small, but these states interact with partial deletion and reserved request capacity.
Potential damage 🟡 Medium 🩹 Recoverable

  • If the changed classification regresses, eligible old versions may remain temporarily, or the cleanup job may stop or fail unnecessarily.
  • A later scheduled run or manual rerun can retry cleanup; no build artifact or consumer data is directly changed by these branches.
  • Reverting the script stops new misclassification.
  • Retained versions are normally repairable by a later successful cleanup run; external package deletion effects are not undone by a revert.
Assessed commit 9b20aea
Diagram

graph TD
  Run["Cleanup run"] --> Read["Read page"] --> ReadLimit{"Rate limited?"} -->|No| Delete["Delete versions"] --> DeleteLimit{"Rate limited?"} -->|Yes| Stop["Stop until next run"]
  ReadLimit -->|Yes| Stop
  ReadLimit -->|Other error| Fail["Fail run"]
  DeleteLimit -->|Other 4xx| Fail
  DeleteLimit -->|Transient error| Retry["Defer version"]
Loading
High-Level Assessment

Keep classification in the existing read and delete paths: both need the full error to recognize long primary-rate-limit messages, and the cleanup already supports stopping until the next run. Waiting within the run would not reliably resolve an exhausted installation limit.

Files changed (1) +25 / -11

Bug fix (1) +25 / -11
cleanup.shStop cleanup on rate limits in reads and deletes +25/-11

Stop cleanup on rate limits in reads and deletes

• Page reads now distinguish rate limits from other failures and stop without retrying a limited request. Delete handling classifies the full error, including follow-up checks, so long primary-rate-limit messages stop the run while logs remain truncated and unrelated failures retain their existing handling.

.github/cleanup.sh

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can tweak Display settings with a live preview to see your comment before it ships

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@viceice
viceice merged commit 34c2f9e into main Nov 26, 2026
3 checks passed
@viceice
viceice deleted the viceice/cleanup-primary-rate-limit branch November 26, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant