Skip to content

fix: keep the bots running through rare API and write failures - #199

Merged
jamesconwaydev merged 6 commits into
mainfrom
fix-wave5-reliability
Nov 6, 2026
Merged

jamesconwaydev merged 6 commits into
mainfrom
fix-wave5-reliability

Conversation

@jamesconwaydev

@jamesconwaydev jamesconwaydev commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Four reliability fixes, one commit per issue, plus two commits from review.

#43 Pagination. list_discussions stops with an error on a repeated or missing endCursor instead of looping until the job times out. GitHub.paginate raises when a page isn't a list, rather than yielding a dict's keys. The test fake does the same for any routed page that isn't a list. Multi-page tests for both.

#47 Odd API answers. A redirect with no Location raises, and a relative one resolves against the request. Retry-After given as an HTTP date is parsed; an unreadable one waits a minute. Network errors now mean any OSError (ssl included) or http.client.HTTPException. One left after the retries is raised as GitHubError(0) with the cause kept, so callers that skip one item on API errors skip it on these too. Which requests retry is unchanged: POSTs and mutations still go out once unless the connection was refused or DNS failed. A GraphQL error entry that isn't an object raises instead of crashing. The fake stops a redirect cycle at MAX_HOPS.

GraphQL RATE_LIMITED already raises RateLimited. Retrying it in place is left for later, so #47 stays open for that.

#39 Like-burst state. If flags.json fails to write after issues were opened, the next run adopts the bot's own open Like issues by title instead of opening them again. It adopts the open aggregate the same way and keeps the entries its body already lists. Only bot-authored issues count, so a title can't be forged. A failed aggregate PATCH is logged and the run continues. An aggregate closed or deleted mid-edit gets a fresh issue for the new entries, so they aren't marked reviewed unseen. One failed issue lookup skips only that record, and a 404 or 410 there reads as deleted.

Known gap: re-adoption only sees open issues. If flags.json is lost and a maintainer has already closed the burst issue, the next run can flag that entry and open a new issue for it.

#37 Failed rename key move. If finish can't move a renamed key in discussions.json, it writes the renames.json record marked pending. on_merge replays pending records onto the mapping before creating threads, then clears the mark, so the next hourly run finishes the move instead of opening a second thread. That includes the rename-collision case, where the stored new key points at the dropped entry's thread. A completed rename is never replayed: relisting and then unlisting the old name can't pull the thread back. A rename's thread is retitled only if the key move or its pending record landed. A drop's thread becomes "Removed: ..." only once its key is gone. If both writes fail, titles and keys stay as they were.

Closes #43
Closes #39
Closes #37
Refs #47

A repeated or missing endCursor now raises instead of refetching the
same page until the job times out, and a REST page that isn't a list
raises instead of yielding a dict's keys as items. Multi-page tests for
both.

Closes #43
A redirect with no Location raises a GitHubError, and a relative one is
resolved against the request. Retry-After as an HTTP date is parsed,
and an unreadable one waits a minute. A network error left after the
retries is raised as a GitHubError, so callers that skip one item on
API errors skip it on these too; which requests retry is unchanged. A
GraphQL error entry that isn't an object raises instead of crashing,
and the test fake stops a redirect cycle after the real client's hop
limit.
A run whose flags.json write fails after it opened issues now leaves a
way back: the next run adopts the bot's own open Like issues, and its
open aggregate, by title instead of opening them again. A failed
aggregate PATCH is logged and the sync goes on; an aggregate closed or
deleted mid-edit gets a fresh issue for the new entries, so they aren't
marked reviewed unseen. One failed issue lookup skips only that record.

Closes #39
When rot's finish couldn't move a renamed entry's key in
discussions.json, nothing tried again, and the hourly on_merge opened a
second thread for the new name. Finish now records renames.json before
the key move and retitles the thread either way; on_merge replays
renames.json onto the mapping before creating anything, so the next
run finishes the move, including after a rename collision. An old name
that is listed again keeps its own key.

Closes #37
Only a renames.json record that rot marked pending, because its
discussions.json move failed, is replayed, and on_merge clears the mark
once it has. A finished rename can no longer pull its thread back after
the old name is relisted and unlisted. Threads are retitled only when
their key is stored or will be: a rename needs the key move or its
pending record, a drop needs its key removed.
ssl and http.client errors now count as network errors, so they retry
and raise as GitHubError like the rest. An adopted aggregate keeps the
entries its body already lists. A 404 on a review lookup reads as a
deleted issue, like a 410. The test fake's paginate raises on a routed
page that isn't a list, as the real client does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant