Skip to content

Commit 4502b9b

Browse files
ampagentPierrunoYT
andcommitted
fix(config): preserve catalog adoption in key transaction
Carry the catalog ownership state introduced by the lower stack through CommitCatalogProviderKey, including legacy-row adoption, and update the serialized repair regression for the stacked return contract. Amp-Thread-ID: https://ampcode.com/threads/T-01a043da-1703-70c5-9d8d-904cd8fd964b Co-authored-by: Pierre Bruno <pierrebruno@hotmail.ch>
1 parent 42f9b81 commit 4502b9b

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎internal/config/writer.go‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,11 +895,18 @@ func CommitCatalogProviderKey(path, catalogID, key string) (EnsuredProvider, err
895895
}
896896
result := EnsuredProvider{}
897897
_, err = runProviderProfileOperation(path, true, false, func(op *providerProfileOperation) error {
898-
owner, owned, err := catalogProviderOwner(op.config.Providers, descriptor.ID)
898+
ownerIndex, ownership, err := catalogProviderOwner(op.config.Providers, descriptor.ID)
899899
if err != nil {
900900
return err
901901
}
902-
if !owned {
902+
owner := ProviderProfile{}
903+
switch ownership {
904+
case catalogOwnershipOwned:
905+
owner = op.config.Providers[ownerIndex]
906+
case catalogOwnershipAdoptable:
907+
op.config.Providers[ownerIndex].CatalogID = descriptor.ID
908+
owner = op.config.Providers[ownerIndex]
909+
case catalogOwnershipNone:
903910
owner = ProviderProfile{Name: descriptor.ID, ProviderKind: providerKindForCatalogTransport(descriptor.Transport), CatalogID: descriptor.ID, BaseURL: descriptor.DefaultBaseURL, Model: descriptor.DefaultModel}
904911
if err := upsertProviderConfig(&op.config, owner, false); err != nil {
905912
return err

‎internal/config/writer_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ func TestRepairUnnamedProviderSerializesWithConcurrentMutation(t *testing.T) {
14521452

14531453
repairDone := make(chan error, 1)
14541454
go func() {
1455-
_, err := RepairUnnamedProvider(path, "work")
1455+
_, _, err := RepairUnnamedProvider(path, "work")
14561456
repairDone <- err
14571457
}()
14581458
<-acquired

0 commit comments

Comments
 (0)