Skip to content

fix: stop role_unreachable emails to customers who disconnected on purpose - #220

Merged
stewartjarod merged 2 commits into
mainfrom
fix/platform-disconnect-clears-record
Oct 28, 2026
Merged

stewartjarod merged 2 commits into
mainfrom
fix/platform-disconnect-clears-record

Conversation

@stewartjarod

Copy link
Copy Markdown
Contributor

Summary

wraps platform disconnect never told the platform, so the dashboard kept webhook_secret and account-health kept sweeping a role the customer deleted on purpose.

 wraps platform disconnect
   removeEventTarget (stack.up)
+  DELETE /v1/connections/:id     # SaaS plane, clears webhook_secret
   deleteConsoleRole              # was the trigger for role_unreachable
   clear local metadata
+    (kept if the DELETE failed, so a re-run can finish)
 account-health: aws.role_unreachable
-  dedupe: last 24h            # daily email, forever
+  dedupe: since roleLastReachableAt   # once per unreachable episode
  • CLI uses getApiBaseUrl() + the SaaS-slot token, not resolveApiTarget(): that follows activeInstance and could null the secret on the customer's own self-hosted plane.
  • Tries each org the token belongs to (a session token otherwise resolves to its active org and 404s on a mismatch). API keys ignore the header.
  • Failure never aborts the AWS teardown. It warns, prints the dashboard path, sets platformRecordCleared: false in JSON, and keeps platform.connectionId; re-running finishes the server half.
  • The worker change is the backstop for customers who disconnected with an older CLI, which can't be fixed from the CLI side.

Evidence

  • Before: TorBox (disconnected 2026-09-17) got aws.role_unreachable daily; first email went out 2026-10-28 once notify started delivering by email.
    After: 9 new tests (8 CLI, 1 worker), red before, green after; src/commands 814/814 and account-health* 46/46 pass, tsc clean.
disconnect(platform-connected account)
  expect order: stack-up -> api-delete -> role-deleted
  expect DELETE https://api.wraps.dev/v1/connections/conn-abc   # even with a self-hosted activeInstance

account-health(role AccessDenied, roleLastReachableAt = T)
  expect hasRecentNotification.since == T                        # was now - 24h

TorBox's webhook_secret was already cleared by hand in production.

Merge Danger

Door: two-way. Revert restores the old behaviour; no schema change.

Blast Radius: narrow. platform disconnect and aws.role_unreachable only.

  • The worker change quiets repeat alerts for any genuinely broken role (one email per episode instead of daily). It re-arms if the role recovers.
  • CLI half only reaches customers after a CLI release.
  • Two other free-plan accounts (fincancegorge, MealPlanAI) still hold a secret with an unreachable role; deliberately left alone.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GxJAQQq5ohyt3UR4EEgCx2

…rpose

`wraps platform disconnect` tore down the AWS side (event target, console
role) but never told the platform, so aws_account kept its webhook_secret.
account-health sweeps every account holding one; with the role deleted it
reported "Wraps can no longer reach your AWS account" and, now that notify
delivers by email, mailed the owner about it.

- cli: `platform disconnect` calls DELETE /v1/connections/:id on the SaaS
  plane (not resolveApiTarget, which can follow a self-hosted
  activeInstance) after the target is removed and before the role is
  deleted. Failure is reported loudly, keeps the connection id, and a
  re-run finishes the server-side half. JSON output gains
  platformRecordCleared.
- api: aws.role_unreachable notifies once per unreachable episode
  (since roleLastReachableAt) instead of daily, as a backstop for
  customers who disconnected with an older CLI.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxJAQQq5ohyt3UR4EEgCx2
@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
wraps-web Skipped Skipped Oct 28, 2026 6:38pm UTC
wraps-website Skipped Skipped Oct 28, 2026 6:38pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – wraps-website October 28, 2026 18:22 Inactive
@vercel
vercel Bot temporarily deployed to Preview – wraps-web October 28, 2026 18:22 Inactive
The baseline architecture rule flags any saveConnectionMetadata that comes
before a deployment in source order. The re-run branch of `platform
disconnect` saves metadata but never deploys, so annotate it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxJAQQq5ohyt3UR4EEgCx2
@vercel
vercel Bot temporarily deployed to Preview – wraps-web October 28, 2026 18:38 Inactive
@vercel
vercel Bot temporarily deployed to Preview – wraps-website October 28, 2026 18:38 Inactive
@stewartjarod
stewartjarod merged commit e08a47b into main Oct 28, 2026
19 of 21 checks passed
@stewartjarod
stewartjarod deleted the fix/platform-disconnect-clears-record branch October 28, 2026 19:45

This branch was previously deployed

2 inactive deployments
Preview – wraps-web — 6eec3cbf Deployed Oct 28, 2026 by vercel[bot]
Preview – wraps-website — 6eec3cbf Deployed Oct 28, 2026 by vercel[bot]
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