Repository navigation
fix(platform): keep custom provider edits whole and version-checked - #3778
Merged
Merged
Conversation
The edit dialog for an organization-defined provider's credential showed the provider's facts from the catalog listing, then read the definition again at Save and sent that fresh hash as the precondition. A dialog opened before another administrator's save therefore wrote its older base URL or API format back over theirs, and the native compare-and-set could not refuse it (#3663). The catalog listing now gives each organization-defined provider the hash of the file its facts were read from, the dialog carries that version with the facts, and the save names it: a definition that moved since is refused with CONFIG_VERSION_CONFLICT ("The provider changed since it was loaded. Reopen the dialog and try again.") instead of being overwritten, and the listing refetches so the reopened dialog reads the newer version. The shared edit dialog stays mounted with its table row, so it now seeds its form on the open transition rather than only at mount: what it shows, and the version it saves against, are the listing's when it opens. Closes #3663
Editing an organization-defined provider's credential saved the provider definition first and the credential second, as two independent writes. When the credential was refused, for example because a sibling credential already carried the new name (409 CREDENTIAL_NAME_TAKEN), the provider's new base URL and display name had already landed and stayed after Cancel (#3662). The dialog now sends one request, POST /api/app/provider-credentials/{id}/with-definition: the credential's fields, its reviewed hash, and the definition with the hash its facts were read at. The door is strict (an unknown field is refused, never dropped) and takes JSON the way the definition door does. The server runs both parts in the definition save's transaction under the providers lock: the definition's compare-and-set first, then the credential row locked FOR UPDATE and updated against its own hash, and the definition file written last. A refused name, a definition or a credential saved since the dialog read it therefore writes neither part. A file that fails its readback, or a transaction that fails to commit after the file was written, puts the reviewed preimage back, and only while the file still holds that save's bytes, so a later writer is never undone. The catalog listing's hash moves with every save, so the hook also refetches the credential reads after a save or a refusal. The new checkCustomProviderCredentialEdit lane proves the rollback on real PostgreSQL, including a credential update undone when the definition file cannot be written. The providers guide (EN/DE/FR) says a save changes both or neither, and the manual layer gains SET-B21. Closes #3662
The credential table rebuilt its column set whenever the credential list changed, because the delete dialog's sibling count was read from a map the columns memo depended on. TanStack renders a function cell as a component, so every rebuilt column set remounted each row's actions, and with them any edit, replace or delete dialog open on the row. Another session's save of any credential in the organization hints the list to refetch, so an administrator's edit in progress vanished, typed input included. Observed while reproducing #3663 in a browser: the older editor closed instead of reaching Save. The sibling count now rides on the row data and the columns stay stable, so the open dialog keeps what was typed, and a save against a moved provider gets its refusal on screen.
This was referenced Sep 28, 2026
This was referenced Sep 29, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two defects in the edit dialog of an organization-defined ("custom") provider's credential. Both are reproduced on
mainin a real browser and fixed here as two distinct regression cases, plus one adjacent defect that the browser reproduction surfaced.PUT …/definitions/{name}→ 200), then the credential (POST …/provider-credentials/{id}→ 409CREDENTIAL_NAME_TAKEN). The new base URL and display name stayed after Cancel.What changed
1.
fix(platform): save a custom provider edit against the version it showed(#3663)GET /api/app/providers/catalogsnow gives each organization-defined provider adefinitionHash: the hash of the file its facts were read from.loadOrgCustomProviderSnapshotstakes the facts and the hash from the same bytes.CONFIG_VERSION_CONFLICT("The provider changed since it was loaded. Reopen the dialog and try again."; the existing message, in all locales) and refetches the listing.CredentialEditDialogstays mounted with its table row, so it now seeds its form when it opens rather than only at mount. It shows, and saves against, the listing as it is at that moment.2.
fix(platform): save custom provider credential and definition together(#3662)New strict door
POST /api/app/provider-credentials/{id}/with-definition, body{name?, modelAllowlist?, endpointUrl?, expectedHash, definition: {config, expectedHash}}. An unknown field gets a 400 rather than being dropped. The body is JSON-only with the definition door's duplicate-key refusal (now the sharedparseNativeJsonBody).updateCredentialWithDefinitionruns both parts inside the definition save's transaction, under the providers config lock:FOR UPDATEand updated throughupdateCredentialagainst its own hash;A duplicate name, a stale definition or a stale credential is therefore refused before either part changes.
saveProviderDefinitiongains analongsidehook. A file that fails its readback gets its reviewed preimage back while the lock still holds.The hook sends one request with both reviewed hashes, and refetches the catalog and credential reads after a save or a refusal. The dialog shows the refusal inline, without the generic "Try again" toast.
The providers guide (EN/DE/FR) says a save changes both parts or neither. The manual layer gains
SET-B21, updated error-code rows and an updated automation register row.3.
fix(platform): keep an open credential dialog across list refetchescolumnsmemo depended on the sibling-count map, and TanStack renders a function cell as a component. Every refetch therefore remounted each row's actions, closing an open edit, replace or delete dialog and discarding what was typed. The count now rides on the row data and the columns stay stable.Review:
90a6c5d18fix(platform): preserve provider saves after uncertain commits(maintainer)60eff1864mergesmain.Verification
All local checks below ran on the exact head
60eff1864unless noted.backend/domains/providers,provider_credentials,configuration-writes,core/lib/providersand the adapter-row suite.providers,credentialsandconnectorssuites pass. Under this sandbox host's load (load average about 20), four typing-heavy add-flow tests hit the 5 s timeout and pass with--testTimeout 30000. Onbd06d45dathe same suites plusdata-residencypassed 192/192 at the default timeout, and CI's UI job passed there.custom-provider-edit.test.ts: real files; success, bug(platform): failed custom-provider credential edit still changes the provider URL and name #3662, bug(platform): stale custom-provider editor overwrites newer settings by reading the latest hash at Save #3663, wrong provider, role gate.routes.with-definition.test.ts: the strict body and coded refusals.credential-edit-dialog.test.tsx: seeds on open, keeps typed input.configuration-writes.test.ts: a failed readback restores the preimage; a lost acknowledgement rewinds nothing and never undoes a later writer.bd06d45da): each mutation turns its guard test red:definitionHashin the listing;ITEST_LANES=checkProviderCredentials,checkProviderCredentialConfiguration,checkCustomProviderCredentialEdit bun run backend:integrationon a disposable pgserver cluster passes 32/33. The one FAIL,knowledge BM25 indexes verified at boot(nopg_searchin pgserver), also fails onmain: the two existing lanes alone give 26/27 there. The lane's six checks, each with readback through the doors a reloaded page reads:CREDENTIAL_NAME_TAKEN, provider unchanged;CONFIG_VERSION_CONFLICT, newer base URL kept;bd06d45da): type-awareoxlinton every changed file,oxfmt --check, local Opengrep (0 findings),lint:manual,check-guideonsettings.md, and the docs locale/link/anchor suites. Type-awareoxlintwas re-run on the files the review commit touched.Browser evidence
This is the local stack (pgserver, backend and Vite) driven by Playwright, on a fresh organization per run. The screenshots and step logs are attached to the tracking task.
maine3943c5f560eff1864(andbd06d45da)PUT definition → 200,POST credential → 409. The definition reads back as display name "B", base URL v2; a reload shows v2POST …/with-definition → 409, inline refusal only. The definition and credential are unchanged (same hash); a reload shows v1. A free name then saves both partsThe visual-aspect-analyzer on the providers page, with and without the edit dialog open, gives the same result on
mainand onbd06d45da: score 98 from two pre-existing load-time layout shifts of the settings layout. Nothing is affected by this change, and no new defect appears.Notes
.invalid, catalog source isnone, and credentials are syntheticTALE_PROVIDER_KEY_TALE77_*env references. The local stack's shipped catalog left out the two live-listing providers (OpenRouter, Vercel AI Gateway); the backend logs show no catalog fetch attempt.expectedHashthe dialog does not send.Closes #3662
Closes #3663