Skip to content

fix(mining): send the re-auth email reliably - #2949

Merged
malek10xdev merged 4 commits into
mainfrom
fix/passive-mining-reauth-email
Oct 23, 2026
Merged

malek10xdev merged 4 commits into
mainfrom
fix/passive-mining-reauth-email

Conversation

@malek10xdev

@malek10xdev malek10xdev commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Sends the passive-mining "needs re-auth" email reliably.

  • imap.helpers.ts: preserve error.status instead of hardcoding 500, so a dead OAuth grant reaches passive-mining as 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 flagged needs_reauth and email them once. A health.notified_at marker prevents repeats.

Tested: backend 693 unit tests, 18 Deno tests, deno check, eslint, tsc.

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.
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Coverage Report

✅ Passed

Commit: 898fa9d

Summary

Name Stmts Branch Funcs Lines
🟡 Total 48.9% 47.8% 54.7% 49.2%
All files
Name Stmts Branch Funcs Lines
🟡 backend/src/controllers/imap.helpers.ts 55.8% 83.3% 50% 58%
No coverage changes
Name Stmts Branch Funcs Lines
🟡 backend/src/controllers/imap.helpers.ts 55.8% 83.3% 50% 58%

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.
@malek10xdev malek10xdev changed the title fix(mining): send the re-auth email when a mining grant dies fix(mining): send the re-auth email reliably Oct 23, 2026
@malek10xdev
malek10xdev merged commit 649f498 into main Oct 23, 2026
14 checks passed
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