Platform credential health check #95
Labels
No labels
bug
devops
duplicate
enhancement
good first issue
layout
next major release
next minor release
question
research
testing
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Depends on
#92 In-app notification infrastructure
lvl0/fedi-feed-router
Reference: lvl0/fedi-feed-router#95
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Periodically verify that platform account credentials are still valid and notify if they expire.
Context
Split from #82. Depends on #92 (notification infrastructure). If Lemmy credentials expire, publishing silently fails. An automated check prevents this.
Tasks
Implemented in
c40e167.Delivered
AccountStatusEnum—untested/healthy/unhealthy, cast onPlatformAccountconsecutive_failures, plus a data update mapping the legacyactive→healthyPlatformAccount::recordCredentialCheckPassed()/recordCredentialCheckFailed()/isUnhealthy(), threshold inFAILURES_BEFORE_UNHEALTHYCheckPlatformCredentialsJob, scheduled dailyCREDENTIAL_EXPIREDnotification on the healthy→unhealthy transitionDesign decisions
Daily, not hourly.
LemmyApiService::login()posts real credentials to a live instance, already carries rate-limit detection, andLemmyRequesthas a 30s timeout. Hourly checks across every active account risk throttling for little benefit — credentials do not expire on an hourly timescale.Unhealthy only after 3 consecutive failures. A network blip, a 502, or an instance restart makes
login()returnnullin exactly the same way expired credentials do. Alerting on the first failure would fire every time the instance restarts. Worst case is ~3 days to detect a genuine expiry, which is the right trade.Found along the way
The
statuscolumn had five undocumented values in circulation:untested(db default + factory),active(CreatePlatformAccountAction), andworking/failed(factory states). Only the first two were known when this started —workingandfailedsurfaced asValueErrorwhen the enum cast met the factory. Verified that nothing inapp/ever wroteworkingorfailed, so no production row can hold them and no backfill was needed for those.Known limitations
down()is not a true inverse — it rewrites everyhealthyrow toactive, including accounts the health check legitimately marked healthy. Acceptable because releases go out by tag rather thanmigrate:rollback. Noted in a comment in the migration.LemmyApiService::login()logs the response body on failure. Lemmy is not believed to echo submitted credentials there, but that is inference, not verified against Lemmy's source. Pre-existing behaviour shared with the manual credential-test flow; this job does not change it.Verification
977 tests / 2553 assertions passing (968 before), Pint clean (308 files), PHPStan clean. Migration run against the dev database — the one existing
activerow converted tohealthycorrectly.An intermittent, unrelated test failure observed during this work is tracked separately as #134.