Repository navigation
fix(mining): send the re-auth email reliably - #2949
Merged
Merged
Conversation
The fallback in generateErrorObjectFromImapError hardcoded 500, which flattened the 401 raised by MiningSourceService.getSourcesForUser and hid the re-auth signal from callers such as passive-mining.
The notification gate depended on the health state read back from its own write. fetch-mining-source has already set needs_reauth by then, so the gate could never pass and passive-mining-failed was never invoked. Replace the two predicates with a plain status check and reuse the same boolean for the health write, so the source lands in needs_reauth and is skipped on the next run.
Coverage Report✅ Passed Commit: 898fa9d Summary
All files
No coverage changes
Generated by Test Coverage Reporter for commit 898fa9d |
Sources in needs_reauth are skipped by the runner, so the transition-based notification can never fire for them. Include them in the run, skip mining, and email once using a health.notified_at marker so it is not repeated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sends the passive-mining "needs re-auth" email reliably.
imap.helpers.ts: preserveerror.statusinstead of hardcoding 500, so a dead OAuth grant reachespassive-miningas 401 (was 500).passive-mining: notify on 401/403 instead of the state-object check that could never pass.passive-mining: also pick up sources already flaggedneeds_reauthand email them once. Ahealth.notified_atmarker prevents repeats.Tested: backend 693 unit tests, 18 Deno tests,
deno check, eslint,tsc.