Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions database/sql/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"errors"
"fmt"
"log/slog"

"gorm.io/gorm"

Expand Down Expand Up @@ -472,14 +471,10 @@ func (s *sqlDatabase) DeleteGiteaCredentials(ctx context.Context, id uint) (err
var creds GiteaCredentials
defer func() {
if err == nil {
forgeCreds, innerErr := s.sqlGiteaToCommonForgeCredentials(creds)
if innerErr != nil {
slog.ErrorContext(ctx, "converting gitea credentials", "error", innerErr)
}
if creds.ID == 0 || creds.Name == "" {
return
}
s.sendNotify(common.GiteaCredentialsEntityType, common.DeleteOperation, forgeCreds)
s.sendNotify(common.GiteaCredentialsEntityType, common.DeleteOperation, params.ForgeCredentials{ID: creds.ID, Name: creds.Name, ForgeType: params.GiteaEndpointType})
}
}()
err = s.conn.Transaction(func(tx *gorm.DB) error {
Expand Down
2 changes: 1 addition & 1 deletion database/sql/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ func (s *sqlDatabase) DeleteGithubCredentials(ctx context.Context, id uint) (err
var name string
defer func() {
if err == nil {
s.sendNotify(common.GithubCredentialsEntityType, common.DeleteOperation, params.ForgeCredentials{ID: id, Name: name})
s.sendNotify(common.GithubCredentialsEntityType, common.DeleteOperation, params.ForgeCredentials{ID: id, Name: name, ForgeType: params.GithubEndpointType})
}
}()
err = s.conn.Transaction(func(tx *gorm.DB) error {
Expand Down
4 changes: 2 additions & 2 deletions database/watcher/watcher_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,8 @@ func (s *WatcherStoreTestSuite) TestGithubCredentialsWatcher() {
s.Require().Equal(common.ChangePayload{
EntityType: common.GithubCredentialsEntityType,
Operation: common.DeleteOperation,
// We only get the ID and Name of the deleted entity
Payload: params.ForgeCredentials{ID: ghCred.ID, Name: ghCred.Name},
// We only get the ID, Name and ForgeType of the deleted entity
Payload: params.ForgeCredentials{ID: ghCred.ID, Name: ghCred.Name, ForgeType: params.GithubEndpointType},
}, event)
case <-time.After(1 * time.Second):
s.T().Fatal("expected payload not received")
Expand Down
5 changes: 4 additions & 1 deletion webapp/src/lib/stores/eager-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,10 @@ class EagerCacheManager {

const credentials = [...state.credentials];
const cred = event.payload as ForgeCredentials;
const matchCred = (c: ForgeCredentials) => c.id === cred.id && c.forge_type === cred.forge_type;
// Derive forge_type from the WebSocket entity type if missing from payload
// (backend delete events may send sparse payloads without forge_type)
const forgeType = cred.forge_type || (event['entity-type'] === 'github_credentials' ? 'github' : 'gitea');
const matchCred = (c: ForgeCredentials) => c.id === cred.id && c.forge_type === forgeType;

if (event.operation === 'create') {
const existingIndex = credentials.findIndex(matchCred);
Expand Down
Loading