Files
conversation-history/SquareMCP/bugs/2026-06-17-health-check-display-bug.md
T

2.8 KiB

Bug: app.squaremcp.com shows TOKEN EXPIRED for connected platforms

Date: 2026-06-17 Severity: Low (cosmetic — publishing still works) Component: app.squaremcp.com UI + GET /api/health/platforms (hermes)


Symptom

After successfully reconnecting Facebook or Instagram via the Connect/Reconnect modal, the platform card continues to display "TOKEN EXPIRED" even after a full page reload. The status never updates to "Connected."


Root Cause

The UI status display is driven by GET /api/health/platforms, which performs a live token validation against each platform's external API. This endpoint returns "status": "expired" for Facebook and Instagram even immediately after a fresh token is saved.

However, GET /api/connections (also called on page load) correctly returns "facebook": true and "instagram": true for the same session.

The two endpoints are inconsistent:

  • GET /api/connections — reflects what is stored in the DB ✅
  • GET /api/health/platforms — re-validates live against external API, returns false-positive expiry ❌

Likely causes (pick one to confirm):

  1. The health check is reading a stale cached token rather than the one just written, OR
  2. The health check calls a Facebook endpoint (e.g. /me/accounts) that the Page Access Token doesn't have permission for, so it gets an auth error and incorrectly treats it as expiry, OR
  3. The health check reads from a different DB field/table than the one POST /api/connect/facebook writes to

Verification

# Immediately after a successful POST /api/connect/facebook:
GET /api/connections       → {"facebook": true, "instagram": true}      ✅
GET /api/health/platforms  → {"platform": "facebook", "status": "expired"} ❌

Expected Behaviour

After a successful POST /api/connect/{platform}, GET /api/health/platforms should return "status": "connected" for that platform.


Suggested Fix

Audit the health/platforms endpoint in hermes:

  1. Log the exact external API call it makes per platform and the response/error it receives
  2. For Facebook/Instagram, change the validation call to something the Page Access Token actually supports — e.g. GET /{page-id}?fields=id instead of GET /me/accounts
  3. Ensure it reads the token from the same DB field that POST /api/connect/facebook writes to
  4. Alternatively, simplify: if GET /api/connections returns true for a platform, treat health as "connected" unless the live check explicitly returns a token-expired error (HTTP 401 with OAuthException code 190 or 102)

Notes

  • Publishing to Facebook and Instagram works correctly despite the UI showing TOKEN EXPIRED — the tokens are valid and stored, the health check is the only thing lying
  • Observed during end-to-end test of Communications Manager GPT on 2026-06-17