Skip to content

Commit 91f7fdd

Browse files
Raderganisback
andauthored
fix: skip metadata scan failures in push callback (#1247)
Co-authored-by: ganisback <370036720@qq.com>
1 parent 061d462 commit 91f7fdd

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

component/callback/git_callback.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,13 +565,13 @@ func (c *gitCallbackComponentImpl) updateModelMetadata(ctx context.Context, file
565565
modelInfo, err := c.runtimeArchComponent.UpdateModelMetadata(ctx, repo)
566566
if err != nil {
567567
slog.Warn("fail to update model metadata", slog.Any("error", err), slog.Any("repo path", repo.Path))
568-
return err
568+
return nil
569569
}
570570
err = c.runtimeArchComponent.UpdateRuntimeFrameworkTag(ctx, modelInfo, repo)
571571
if err != nil {
572572
slog.Warn("fail to update runtime framework tag", slog.Any("error", err), slog.Any("repo path", repo.Path))
573573
}
574-
return err
574+
return nil
575575
}
576576

577577
// check if the repo is valid for runtime framework

component/callback/git_callback_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package callback
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"testing"
78
"time"
@@ -211,6 +212,30 @@ func TestGitCallbackComponentImpl_UpdateRepoInfos(t *testing.T) {
211212
err := gc.UpdateRepoInfos(context.Background(), req)
212213
assert.NoError(t, err)
213214
})
215+
216+
t.Run("should skip model metadata update failure", func(t *testing.T) {
217+
gc := initializeTestGitCallbackComponent(context.Background(), t)
218+
req := &types.GiteaCallbackPushReq{
219+
Ref: "refs/heads/main",
220+
Repository: types.GiteaCallbackPushReq_Repository{
221+
FullName: "models_namespace/repo",
222+
},
223+
Commits: []types.GiteaCallbackPushReq_Commit{
224+
{
225+
Modified: []string{"config.json"},
226+
Removed: []string{"old_file.txt"},
227+
},
228+
},
229+
}
230+
231+
gc.mocks.stores.RepoMock().EXPECT().FindByPath(ctx, types.ModelRepo, "namespace", "repo").Return(repo, nil)
232+
gc.mocks.runtimeArchComponent.EXPECT().UpdateModelMetadata(ctx, repo).Return(nil, errors.New("unsupported model format unknown"))
233+
gc.mocks.stores.RepoMock().EXPECT().FindByPath(ctx, types.ModelRepo, "namespace", "repo").Return(repo, nil)
234+
gc.mocks.tagComponent.EXPECT().UpdateLibraryTags(ctx, types.ModelTagScope, "namespace", "repo", "old_file.txt", "").Return(nil)
235+
236+
err := gc.UpdateRepoInfos(context.Background(), req)
237+
assert.NoError(t, err)
238+
})
214239
}
215240

216241
func TestGitCallbackComponentImpl_CalculateRepoSize(t *testing.T) {

0 commit comments

Comments
 (0)