Reset access source name sync on connection change
Once the source-name worker sets name_synced_at, nothing cleared it, so a source that hit a terminal failure (Brex 403, wrong Sentry org slug) kept its generic name forever — even after the user reconnected with the right scope or picked the correct org, contradicting the Brex guidance to reconnect. Clear name_synced_at whenever the connection changes: on UpdateSource when a connector is (re)set, inside ConfigureAccessReviewSource when the org is (re)selected, and on the OAuth reconnect path via the new ResetSourceNameSyncForConnector service method. The worker then re-claims the row and re-resolves the display name. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -184,6 +184,11 @@ func (s *Service) UpdateSource(
|
||||
}
|
||||
|
||||
source.ConnectorID = *req.ConnectorID
|
||||
|
||||
// A (re)linked connector may resolve to a different instance
|
||||
// name; clear the synced flag so the source-name worker picks
|
||||
// the row up and re-resolves it.
|
||||
source.NameSyncedAt = nil
|
||||
}
|
||||
|
||||
if req.CsvData != nil {
|
||||
@@ -444,6 +449,16 @@ func (s *Service) ConfigureAccessReviewSource(
|
||||
return fmt.Errorf("cannot update connector: %w", err)
|
||||
}
|
||||
|
||||
// The selected org changed, so the resolvable instance name may
|
||||
// have too; clear the synced flag so the source-name worker
|
||||
// re-resolves the display name.
|
||||
source.NameSyncedAt = nil
|
||||
source.UpdatedAt = time.Now()
|
||||
|
||||
if err := source.Update(ctx, conn, scope); err != nil {
|
||||
return fmt.Errorf("cannot reset access source name sync: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
@@ -453,3 +468,22 @@ func (s *Service) ConfigureAccessReviewSource(
|
||||
|
||||
return source, nil
|
||||
}
|
||||
|
||||
// ResetSourceNameSyncForConnector clears the synced-name flag on every access
|
||||
// source backed by connectorID so the source-name worker re-resolves the
|
||||
// display name. Called after a connector is reconnected — the new grant may
|
||||
// scope a different org/workspace, changing the resolvable name.
|
||||
func (s *Service) ResetSourceNameSyncForConnector(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
connectorID gid.GID,
|
||||
) error {
|
||||
return s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Tx) error {
|
||||
sources := &coredata.AccessReviewSources{}
|
||||
|
||||
return sources.ClearNameSyncedAtByConnectorID(ctx, conn, scope, connectorID)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user