Skip to content

Report purge failures instead of returning an empty status - #10

Open
biast12 wants to merge 1 commit into
masterfrom
purger
Open

Report purge failures instead of returning an empty status#10
biast12 wants to merge 1 commit into
masterfrom
purger

Conversation

@biast12

@biast12 biast12 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Description

When a guild purge fails the client logs "logarchiver purge failed" with nothing to act on, because status.errors is always empty. RemoveQueue.AddError and AddRemovedObject lost their only callers in 4efab9e and have been dead code since; failure reasons only ever reached our own logger.

  • Wired AddError into all five failure paths (bucket parse, S3 client lookup, object listing, object removal, database) and AddRemovedObject on success. This also refreshes LastUpdated, which fixes the reaper force-flipping any purge running past 10 minutes to timeout.

  • Changed RemoveOperation.Errors from map[string]error to map[string]string. Required, not cosmetic: map[string]error marshals every value to {} and archiverclient.PurgeStatus decodes into map[string]string, so populating the map without this would have turned every failed purge into a client-side decode error. Verified:

    old server payload: {"errors":{"obj":{}}}
    client decode: json: cannot unmarshal object into Go struct field client.errors of type string

Backward-compatible: existing clients already expect map[string]string and until now only ever received {}.

  • A bucket-wide ListObjects failure was logged as "non-fatal" and never set firstErr, producing complete with zero deletions — a silent purge failure the caller reports as success, after which it purges the database. It now fails the operation. The error travels back over a channel since firstErr belongs to the outer goroutine.
  • Objects().DeleteByGuild ran unconditionally, so a failed S3 delete still dropped the object→bucket mapping and stranded the transcripts with no record of where they live. Now only runs once the objects are actually gone.

For: TicketsBot-cloud/cleanupdaemon#4

THE LOGARCHIVER NEEDS TO BE BUMPED IN THE ARCHIVERCLIENT

Type of Change

  • Bug fix
  • New feature
  • Breaking change

Checklist

  • My code follows the style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Store remove-queue errors as strings instead of `error` values so JSON responses serialize correctly and clients can decode them reliably. Also record purge failures from DB list/delete, bucket parsing/client lookup, and object removal into `RemoveQueue` so operation status reflects all encountered errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants