Skip to content

fix(den): return reconnect guidance for rejected native Google refreshes - #4524

Open
benjaminshafii wants to merge 13 commits into
devfrom
fix/den-api-12-native-refresh-0905
Open

benjaminshafii wants to merge 13 commits into
devfrom
fix/den-api-12-native-refresh-0905

Conversation

@benjaminshafii

@benjaminshafii benjaminshafii commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

A native Google capability call with a rejected OAuth refresh grant returned 500 internal_server_error. The shared resolver now returns the existing actionable 409 needs_connection response, or reuses a newer valid credential if another refresh or reconnect has already saved one. Microsoft 365 also uses this resolver; its rejected-grant response changes from 502 to 409.

Only oauth_invalid_grant is handled as reconnect. Other token failures retain their existing behavior. The error path never clears credentials, so a stale rejection cannot erase a newer grant or invalidate another worker's pending persistence. There is no automatic retry inside the request. Explicit later requests still try the retained grant, and status still reports connected: true while an access token is stored; this existing status limitation is now asserted, not claimed fixed.

Related Sentry issue: DEN-API-12. The production-tagged den-api.local URL is used by internal MCP invocation and does not alone establish test traffic. The historical reason Google rejected the grant remains unknown. This native-provider path is distinct from #4441's OpenWork-issued MCP refresh grants.

Validation:

  • Current candidate: b7a646b03201a3aca6391c7f92dabe555096a62c. Passed: 1 test, 16 assertion groups, 0 failures, 0 skips, 0 pending judgments. Final-head proof job; matching-SHA evidence. The concurrency check verifies credential reuse without another refresh. The historical compatibility-only switch has been removed: rejected-grant cases always run.
  • Command: OPENWORK_EVAL_NATIVE_GOOGLE_REFRESH=1 pnpm evals:pr specs/native-google-refresh-recovery.test.ts.
  • The expanded journey drives the real Google and Microsoft default resolvers through HTTP with synthetic OAuth and mail endpoints. It covers three repeated rejected-grant requests without mailbox access; temporary provider failure followed by recovery; fresh-token reads without refresh; two concurrent successful refreshes; successful and rejected refreshes held across reconnect and disconnect. Credential fingerprints prove that late responses do not overwrite a completed reconnect.
  • Historical clean-dev control: product source aadaff1530fc5a80a7fff8671a5c3266aa62d989, 1 test and 10 unchanged-behavior assertion groups passed, zero skips. Only the test and synthetic fixture were overlaid; this historical control predates the additional concurrency persistence assertions and removal of the compatibility-only switch in the final candidate. The control deliberately excludes the new rejected-grant semantics.
  • The earlier unchanged-product reproduction at 12563e7e897ce47d654e8e9c0db23906612cff88 returned 500 where 409 was required: failing control job.
  • The permanent required job runs final-head proof only and rejects skipped outcomes. The temporary clean-dev comparison matrix was removed after recording its evidence; no security gate was weakened.
  • New spec boundary classification passes. Existing repository-wide boundary/channel ratchet failures were identical on the original branch and clean dev control 85a5dfccb4d74732593628ab4cc8912f8b88283d; no baseline was weakened.

Remaining gaps: strict provider refresh-token rotation, omitted refresh-token responses, tenant/client rotation or member removal during refresh, cross-member/connector isolation, desktop reconnect-card behavior, and latency/load measurements. Those behaviors are not claimed proven by this journey. All fixtures and published evidence are synthetic; no production payloads or credentials are used.

@vercel

vercel Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

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

4 Skipped Deployments
Project Deployment Actions Updated
openwork-app Ignored Ignored Preview Sep 5, 2026 10:49pm UTC
openwork-den Ignored Ignored Preview Sep 5, 2026 10:49pm UTC
openwork-diagnostics Ignored Ignored Preview Sep 5, 2026 10:49pm UTC
openwork-landing Ignored Ignored Preview Sep 5, 2026 10:49pm UTC

@vercel
vercel Bot temporarily deployed to Preview – openwork-den September 5, 2026 18:11 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-app September 5, 2026 18:11 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics September 5, 2026 18:11 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-landing September 5, 2026 18:11 Inactive
@benjaminshafii
benjaminshafii marked this pull request as ready for review September 5, 2026 18:17
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Deploying openwork with  Cloudflare Pages  Cloudflare Pages

Latest commit: cec80d0
Status: ✅  Deploy successful!
Preview URL: https://af9cdfbd.openwork.pages.dev
Branch Preview URL: https://fix-den-api-12-native-refres.openwork.pages.dev

View logs

@vercel
vercel Bot temporarily deployed to Preview – openwork-app September 5, 2026 19:53 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-landing September 5, 2026 19:53 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-den September 5, 2026 19:53 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics September 5, 2026 19:53 Inactive
Comment thread .github/workflows/ci-tests.yml Fixed
Comment thread .github/workflows/ci-tests.yml Fixed
Comment thread .github/workflows/ci-tests.yml Fixed
@benjaminshafii

Copy link
Copy Markdown
Member Author

Historical clean-dev compatibility control — Passed

This is control evidence, not final PR-head evidence. Production source: clean dev at aadaff1530fc5a80a7fff8671a5c3266aa62d989. Only the journey and synthetic provider fixture were overlaid from 5ec783daa5a292fbdafac04bfea12f9fca0efeb8; those two files are byte-identical to the final candidate 86978f2399d7282607f9154157eb2b0a29214a02.

Completed control job · Original test-run artifact

1 test passed; 10 assertion groups passed; 0 failed; 0 skipped; 0 pending judgments. Cold-booted Den and isolated database on the Linux runner; synthetic OAuth/Google/Graph endpoints. No production services used.

Reproduction on clean dev with the two witness files overlaid:

OPENWORK_EVAL_NATIVE_GOOGLE_REFRESH=1 OPENWORK_EVAL_NATIVE_REFRESH_COMPATIBILITY_ONLY=1 pnpm evals:pr specs/native-google-refresh-recovery.test.ts

This mode checks unchanged valid behavior for both real default resolvers. It intentionally excludes the six PR-only rejected-grant assertion groups; it does not claim that clean dev already returns the new 409 behavior.

  • PASS — google-workspace: Temporary failures preserve recovery: Provider unavailability retained the existing error classification (Google 500; Microsoft 502). The next read refreshed successfully without another authorization.
  • PASS — google-workspace: Fresh credentials avoid token-endpoint work: Two valid-token mail reads succeeded without any refresh attempt.
  • PASS — google-workspace: Concurrent successful refreshes retain a usable successor: Two held successful refresh responses completed concurrently; both waiting reads and a later read succeeded.
  • PASS — google-workspace: successful refresh cannot overwrite reconnect: A new authorization completed while the old refresh was held. The waiting read and a subsequent read used the exact replacement credential fingerprint, without another refresh.
  • PASS — google-workspace: Disconnect wins over successful refresh: Disconnect completed before the held token response. Both waiting and later reads required connection, status remained disconnected, and no mail call or additional refresh occurred.
  • PASS — microsoft-365: Temporary failures preserve recovery: Provider unavailability retained the existing error classification (Google 500; Microsoft 502). The next read refreshed successfully without another authorization.
  • PASS — microsoft-365: Fresh credentials avoid token-endpoint work: Two valid-token mail reads succeeded without any refresh attempt.
  • PASS — microsoft-365: Concurrent successful refreshes retain a usable successor: Two held successful refresh responses completed concurrently; both waiting reads and a later read succeeded.
  • PASS — microsoft-365: successful refresh cannot overwrite reconnect: A new authorization completed while the old refresh was held. The waiting read and a subsequent read used the exact replacement credential fingerprint, without another refresh.
  • PASS — microsoft-365: Disconnect wins over successful refresh: Disconnect completed before the held token response. Both waiting and later reads required connection, status remained disconnected, and no mail call or additional refresh occurred.

The temporary baseline matrix was removed after this one-off comparison. The permanent required job verifies only the current PR head; its fresh evidence is published separately. No security check was suppressed or weakened.

@benjaminshafii
benjaminshafii enabled auto-merge (squash) September 5, 2026 22:43
@benjaminshafii

Copy link
Copy Markdown
Member Author

Test evidence — native-google-refresh-and-microsoft-compatibility-preserve-reconnect-and-disconn — ✅ passed

SHA b7a646b · engine v1

✅ passed · 16 expectations passed · 0 failed · 0 pending

verdict passed · 0 user observations · 0 probes · steps 0/0

ℹ️ ASSERTION — 1. google-workspace: Repeated revoked grants return 409 without mailbox access

Three explicit reads made exactly three refresh attempts and no mailbox requests. Status continued to report connected: true: retained credentials are an existing UI-status limitation, not a claim of durable invalidation.

  • ✅ PASS google-workspace: Repeated revoked grants return 409 without mailbox access — Three explicit reads made exactly three refresh attempts and no mailbox requests. Status continued to report connected: true: retained credentials are an existing UI-status limitation, not a claim of durable invalidation.

ℹ️ ASSERTION — 2. google-workspace: Temporary failures preserve recovery

Provider unavailability retained the existing error classification (Google 500; Microsoft 502). The next read refreshed successfully without another authorization.

  • ✅ PASS google-workspace: Temporary failures preserve recovery — Provider unavailability retained the existing error classification (Google 500; Microsoft 502). The next read refreshed successfully without another authorization.

ℹ️ ASSERTION — 3. google-workspace: Fresh credentials avoid token-endpoint work

Two valid-token mail reads succeeded without any refresh attempt.

  • ✅ PASS google-workspace: Fresh credentials avoid token-endpoint work — Two valid-token mail reads succeeded without any refresh attempt.

ℹ️ ASSERTION — 4. google-workspace: Concurrent successful refreshes retain a usable successor

Two held successful refresh responses completed concurrently; both waiting reads succeeded. A later read succeeded without another refresh and used a credential fingerprint observed on the concurrent mailbox reads.

  • ✅ PASS google-workspace: Concurrent successful refreshes retain a usable successor — Two held successful refresh responses completed concurrently; both waiting reads succeeded. A later read succeeded without another refresh and used a credential fingerprint observed on the concurrent mailbox reads.

ℹ️ ASSERTION — 5. google-workspace: successful refresh cannot overwrite reconnect

A new authorization completed while the old refresh was held. The waiting read and a subsequent read used the exact replacement credential fingerprint, without another refresh.

  • ✅ PASS google-workspace: successful refresh cannot overwrite reconnect — A new authorization completed while the old refresh was held. The waiting read and a subsequent read used the exact replacement credential fingerprint, without another refresh.

ℹ️ ASSERTION — 6. google-workspace: Disconnect wins over successful refresh

Disconnect completed before the held token response. Both waiting and later reads required connection, status remained disconnected, and no mail call or additional refresh occurred.

  • ✅ PASS google-workspace: Disconnect wins over successful refresh — Disconnect completed before the held token response. Both waiting and later reads required connection, status remained disconnected, and no mail call or additional refresh occurred.

ℹ️ ASSERTION — 7. google-workspace: invalid_grant cannot overwrite reconnect

A new authorization completed while the old refresh was held. The waiting read and a subsequent read used the exact replacement credential fingerprint, without another refresh.

  • ✅ PASS google-workspace: invalid_grant cannot overwrite reconnect — A new authorization completed while the old refresh was held. The waiting read and a subsequent read used the exact replacement credential fingerprint, without another refresh.

ℹ️ ASSERTION — 8. google-workspace: Disconnect wins over invalid_grant

Disconnect completed before the held token response. Both waiting and later reads required connection, status remained disconnected, and no mail call or additional refresh occurred.

  • ✅ PASS google-workspace: Disconnect wins over invalid_grant — Disconnect completed before the held token response. Both waiting and later reads required connection, status remained disconnected, and no mail call or additional refresh occurred.

ℹ️ ASSERTION — 9. microsoft-365: Repeated revoked grants return 409 without mailbox access

Three explicit reads made exactly three refresh attempts and no mailbox requests. Status continued to report connected: true: retained credentials are an existing UI-status limitation, not a claim of durable invalidation.

  • ✅ PASS microsoft-365: Repeated revoked grants return 409 without mailbox access — Three explicit reads made exactly three refresh attempts and no mailbox requests. Status continued to report connected: true: retained credentials are an existing UI-status limitation, not a claim of durable invalidation.

ℹ️ ASSERTION — 10. microsoft-365: Temporary failures preserve recovery

Provider unavailability retained the existing error classification (Google 500; Microsoft 502). The next read refreshed successfully without another authorization.

  • ✅ PASS microsoft-365: Temporary failures preserve recovery — Provider unavailability retained the existing error classification (Google 500; Microsoft 502). The next read refreshed successfully without another authorization.

ℹ️ ASSERTION — 11. microsoft-365: Fresh credentials avoid token-endpoint work

Two valid-token mail reads succeeded without any refresh attempt.

  • ✅ PASS microsoft-365: Fresh credentials avoid token-endpoint work — Two valid-token mail reads succeeded without any refresh attempt.

ℹ️ ASSERTION — 12. microsoft-365: Concurrent successful refreshes retain a usable successor

Two held successful refresh responses completed concurrently; both waiting reads succeeded. A later read succeeded without another refresh and used a credential fingerprint observed on the concurrent mailbox reads.

  • ✅ PASS microsoft-365: Concurrent successful refreshes retain a usable successor — Two held successful refresh responses completed concurrently; both waiting reads succeeded. A later read succeeded without another refresh and used a credential fingerprint observed on the concurrent mailbox reads.

ℹ️ ASSERTION — 13. microsoft-365: successful refresh cannot overwrite reconnect

A new authorization completed while the old refresh was held. The waiting read and a subsequent read used the exact replacement credential fingerprint, without another refresh.

  • ✅ PASS microsoft-365: successful refresh cannot overwrite reconnect — A new authorization completed while the old refresh was held. The waiting read and a subsequent read used the exact replacement credential fingerprint, without another refresh.

ℹ️ ASSERTION — 14. microsoft-365: Disconnect wins over successful refresh

Disconnect completed before the held token response. Both waiting and later reads required connection, status remained disconnected, and no mail call or additional refresh occurred.

  • ✅ PASS microsoft-365: Disconnect wins over successful refresh — Disconnect completed before the held token response. Both waiting and later reads required connection, status remained disconnected, and no mail call or additional refresh occurred.

ℹ️ ASSERTION — 15. microsoft-365: invalid_grant cannot overwrite reconnect

A new authorization completed while the old refresh was held. The waiting read and a subsequent read used the exact replacement credential fingerprint, without another refresh.

  • ✅ PASS microsoft-365: invalid_grant cannot overwrite reconnect — A new authorization completed while the old refresh was held. The waiting read and a subsequent read used the exact replacement credential fingerprint, without another refresh.

ℹ️ ASSERTION — 16. microsoft-365: Disconnect wins over invalid_grant

Disconnect completed before the held token response. Both waiting and later reads required connection, status remained disconnected, and no mail call or additional refresh occurred.

  • ✅ PASS microsoft-365: Disconnect wins over invalid_grant — Disconnect completed before the held token response. Both waiting and later reads required connection, status remained disconnected, and no mail call or additional refresh occurred.

Test run created 2026-09-05T22:50:52.082Z · Source: evals/results/test-runs/2026-09-05T22-50-52-082Z-native-google-refresh-and-microsoft-compatibility-preserve-reconnect-and-disconn/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4524 --test-run 2026-09-05T22-50-52-082Z-native-google-refresh-and-microsoft-compatibility-preserve-reconnect-and-disconn

This branch was successfully deployed

4 active (outdated) deployments
Preview – openwork-landing — 86978f23 Deployed Sep 5, 2026 by vercel[bot]
Preview – openwork-den — 86978f23 Deployed Sep 5, 2026 by vercel[bot]
Preview – openwork-app — 86978f23 Deployed Sep 5, 2026 by vercel[bot]
Preview – openwork-diagnostics — 86978f23 Deployed Sep 5, 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.

2 participants