Repository navigation
fix(platform): add or reconnect exactly the OAuth credential chosen - #3729
Conversation
Every completed consent for a connector without a workspace id (Gmail, Outlook, Google Drive, Teams) renewed the connector's default grant: a second account added through Add credential silently replaced the first, and Reconnect on any other row rewrote the default instead (#3711). The pending authorization now carries the intent. Migration 0130 adds app.connector_oauth_states.reconnect_credential_id (NULL = Add, no foreign key); the start door takes an optional credentialId and keeps it only when it names an OAuth grant of that organization and connector. The callback reads the intent from the consumed row alone, re-checks the initiator's membership and developer role, and refuses a Reconnect whose credential is gone before redeeming the code. storeOauth2Grant runs as one transaction under a per-(organization, connector) advisory lock, row-locks the Reconnect target before reading the siblings, and lets a pure planner decide: Add stores a new credential under a free name, Reconnect renews exactly its credential (needs-reauth cleared, disabled kept) or saves nothing, Slack keeps one credential per workspace and refuses a Reconnect into another. Every credential create takes the same pair lock, so concurrent first adds no longer die on the name or default index. New fixed pages: credential_missing, account_mismatch, forbidden. The native-Postgres lane checkConnectorOauthIntent proves each case; the claim-race probe's initiator is now a member of its organization.
Connect and Reconnect sent the browser to the same start URL, so nothing told the callback which credential a consent was for (#3711). goToAuthorization now takes an explicit intent: Add credential > Connect starts an Add that names no credential, and a row's Reconnect names that row's id. The parameter name is shared with the start door (lib/shared/connector-consent.ts), so the page and the door cannot drift into a Reconnect that silently lands as an Add.
The connector guides promised that Add credential connects another account and that Reconnect keeps the credential's name and references, while the product renewed the default grant for both (#3711). EN, DE and FR now say what each does: every Connect adds a new credential (named after the connector and numbered, renamed through Edit credential), Slack keeps one credential per workspace, Reconnect renews exactly the row it was chosen on and leaves a disabled credential disabled, and a removed credential, a lost role or another Slack workspace saves nothing. The connectors manual suite asserts the rows by their masked previews, explains how to run the consent boxes against a loopback fake vendor, and gains CONN-F19/F20 and CONN-B7-B10; the automation, pins and error-code registers name the new coverage and pages.
yannickmonney
left a comment
There was a problem hiding this comment.
Reviewed 8596a69b6493774a671e6db0b43b2804995ccaa8 locally. The Add/named-Reconnect behavior, state binding, refusal and expiry controls, deleted-target behavior, concurrent Adds, and Slack workspace behavior pass the scoped native checks.
[P2] Localize the new OAuth recovery pages before shipping. The new credential_missing, account_mismatch, and forbidden messages at services/platform/backend/core/http_connectors/error_page.ts:90–106 are English-only. The shared renderer always emits lang="en" and has no locale input. A local request to the new invalid-Reconnect path with either Accept-Language: de or fr returns 404 with “This credential cannot be reconnected” and “Back to connector settings”. These are new user-facing recovery states, so they must ship in EN/DE/FR under .agents/repo.md's locale rule. The older errors already used this English-only renderer; this finding is the added messages extending that gap, not a claim that the renderer became unlocalized in this PR. Please route them through one localized error surface with translated heading, explanation and back link, and test the native route in EN/DE/FR. Preserve the fixed-copy/escaping and no-store protections.
Independent validation: 83 focused backend tests at this head; 24 affected client tests and 171 docs structural tests on the unchanged UI/docs tree from 15007de31; real-Postgres filtered integration run 30/30, including 13 OAuth intent checks, with only the token response faked. No real provider or production Tale was contacted. This is scoped review, not a full local bun run check or rendered-docs/browser-layout approval.
Parent verification: I also read the changed renderer and replayed the local native EN/DE/FR invalid-target proof at this head; the English-only result and zero external calls reproduced. No additional finding count is assigned to this review comment.
yannickmonney
left a comment
There was a problem hiding this comment.
Re-reviewed 4fbc89ab88a0a979e400ef38861a18544c0ca9ac. The requested locale correction is resolved: all three new recovery pages now provide EN/DE/FR headings, explanations and back links, with matching language metadata. Independent native route checks passed for all three errors and regional/fallback/escaping controls.
Validation at this head: 101 focused backend tests, 24 affected client tests and 20 independent native/renderer cases passed. The OAuth storage, intent, migration and connector UI sources are byte-identical to the previously reviewed implementation; its earlier native integration evidence is retained with that version explicitly recorded. Tests add locale coverage without weakening existing assertions. All testing used local synthetic fixtures and fake provider responses.
No blocking finding remains in this reviewed delta. This is scoped review; no full local bun run check or new browser-layout approval is claimed.
Parent independently read the locale delta and proof and replayed the 20 native/renderer cases successfully.
|
TALE-80 review response: evidence at the exact merged head (re: review 5342854423) Scope. Everything below ran on PR head
Localization, in a real browser.
Slack.
Unit and CI.
Remaining limitations at this head.
Unmerged follow-up. A change covering items 1–3 exists as two local, unpushed commits on top of
|
Closes #3711.
Connect and Reconnect previously used the same OAuth start URL, so adding a second account or reconnecting a non-default row could overwrite the default credential. The browser now sends an explicit Add or the selected credential ID. The single-use server state carries that intent through consent; callback query parameters cannot retarget it.
The callback checks the initiating session, current membership and developer capability, then rechecks the selected grant. Grant storage uses one transaction with a connector-pair advisory lock and a lock on the selected credential. Add creates a distinct name and preserves existing credentials; Reconnect preserves the selected ID, name, default choice and references. A disabled credential stays disabled. Slack retains one credential per workspace and refuses reconnecting a row to a different workspace.
Review found and fixed a further authorization race: a member removed or demoted while the token exchange waited could still renew a credential. Storage now locks the member row and repeats the existing authorization check inside its transaction. A revocation committed first refuses the write; one that starts later waits for commit. The pre-exchange check remains.
Migration
0131_connector_oauth_reconnect_target.sqladds nullablereconnect_credential_id. It deliberately has no foreign key, so deleting a target cannot turn a pending Reconnect into Add or erase its refusal context. Legacy pending rows read as Add. The previous image can continue using its original column list during a rolling deployment; callbacks completed by that older image still have its previous behavior.The three new refusal pages (
credential_missing,account_mismatch,forbidden) and their return link support EN/DE/FR using the shared language parser, including DE-CH fallback. Existing refusal kinds retain their existing English behavior. Updated product docs cover all three locales, and the manual/automation registers cover intent, authorization and recovery.Validation from the independent review:
Final integration with main
2be6c267e: 215 scoped server tests, 51 component tests, 46/46 real PostgreSQL checks, full platform typecheck, the 1228-box manual gate, and all 18 rebuilt Chromium handoffs passed. The start-door 403 messages were confirmed to be pre-existing on main. Member/SCIM removal lock order is compatible; a pre-existing contention with whole-organization deletion can still roll an OAuth store back asstorage_failed.Whole repository CI must complete on the final pushed head before merge. Local checks above are scoped runs, not a claim that the entire repository gate ran locally.
Integrated the shipped recurrence migration unchanged as
0130_task_repeat.sql; OAuth now follows it as0131_connector_oauth_reconnect_target.sql. Fresh PostgreSQL boot and the connector-credential, OAuth-intent and recurrence lanes passed 47/47 after this refresh.