Skip to content

fix(integrations): send a single notification when a token refresh fails#1678

Open
giladresisi wants to merge 1 commit into
mainfrom
fix/duplicate-refresh-error-email
Open

fix(integrations): send a single notification when a token refresh fails#1678
giladresisi wants to merge 1 commit into
mainfrom
fix/duplicate-refresh-error-email

Conversation

@giladresisi

Copy link
Copy Markdown
Collaborator

Problem

Every failed token refresh notifies (in-app + email) the user twice:

  1. refreshProcess (refresh.integration.service.ts) calls informAboutRefreshError with the failure cause — email titled Could not refresh your <provider> channel <cause>.
  2. It then calls integrationService.disconnectChannel, which internally calls informAboutRefreshError again, without the cause — a second email titled Could not refresh your <provider> channel.

The disconnectChannel call contributes nothing else in this path: the refreshNeeded call two lines earlier already sets the exact same refreshNeeded: true flag that disconnectChannel's repository call sets.

Fix

Remove the disconnectChannel call from refreshProcess's failure branch. The user still gets exactly one notification — the informative one that includes the failure cause — and the channel is still flagged as needing reconnection. disconnectChannel itself is untouched, so its other callers (analytics token-expiry path, public API, chat tool) keep their existing notify-on-disconnect behavior.

Repro & validation

  • Repro (before fix): connected an Instagram (Facebook Business) channel holding an invalid access token, then triggered a post. The publish failed with a token error, the refresh attempt failed (Instagram cannot refresh), and two emails arrived for the single failure — one with the cause in the title, one without.
  • Validation (after fix): repeated the exact same scenario — exactly one email arrived (the one including the failure cause), and the channel was still marked as needing reconnection (red badge + blocked posting), as expected.

🤖 Generated with Claude Code

When a token refresh fails, refreshProcess sent the refresh-error
notification (with the failure cause) and then called disconnectChannel,
which sends the same notification again without the cause. Every failed
refresh therefore emailed the user twice: once titled "Could not refresh
your <provider> channel <cause>" and once "Could not refresh your
<provider> channel".

Drop the disconnectChannel call from the failure branch: the
refreshNeeded call two lines earlier already sets the same flag
disconnectChannel would, so the only thing it added was the duplicate
email. disconnectChannel itself is unchanged for its other callers.

Reproduced by triggering a post on an Instagram channel holding an
invalid token (refresh fails since the provider cannot refresh) — two
emails arrived for the single failure. After the fix, the same scenario
produces exactly one email (the one including the failure cause), and
the channel is still flagged as needing reconnection.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@postiz-contribution postiz-contribution Bot added the contribution:approved Approved contributor label Jul 6, 2026
@postiz-contribution

Copy link
Copy Markdown

Contribution-checker quality warning
Heuristic score: 12/100 (low). This is a non-blocking warning surfaced by the project's quality settings.

Heuristics that flagged:

  • Excessive inline code references: 14 inline refs (>3)
  • PR doesn't use the repo's PR template: 5 required checkbox items missing (max 1, match ≥80%)
  • Body adds too many extra headers beyond the template: 3 extra headers (>1)
  • AI watermark phrase: Matched: "Generated with Claude Code"
  • Commit message too long: Longest: 1098 chars

If this is a genuine contribution, please add detail to your PR description and tighten the diff scope before reviewers look at it.

@postiz-agent

postiz-agent Bot commented Jul 6, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution:approved Approved contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant