diff --git a/src/server/middleware/subject/subject.go b/src/server/middleware/subject/subject.go index 66e887baf76..6354134a3ef 100644 --- a/src/server/middleware/subject/subject.go +++ b/src/server/middleware/subject/subject.go @@ -156,7 +156,7 @@ func Middleware() func(http.Handler) http.Handler { // In certain cases, the OCI client may push the subject artifact and accessory in either order. // Therefore, it is necessary to handle situations where the client pushes the accessory ahead of the subject artifact. digest := digest.FromBytes(body) - accs, err := accessory.Mgr.List(ctx, q.New(q.KeyWords{"SubjectArtifactDigest": digest})) + accs, err := accessory.Mgr.List(ctx, q.New(q.KeyWords{"SubjectArtifactDigest": digest, "SubArtifactRepo": info.Repository})) if err != nil { logger.Errorf("failed to list accessory artifact: %s, error: %v", digest, err) return err diff --git a/src/server/middleware/subject/subject_test.go b/src/server/middleware/subject/subject_test.go index 4ba5bbad4c5..907fb649a3a 100644 --- a/src/server/middleware/subject/subject_test.go +++ b/src/server/middleware/subject/subject_test.go @@ -149,6 +149,7 @@ func (suite *MiddlewareTestSuite) addArtAcc(pid, repositoryID int64, repositoryN ID: 1, ArtifactID: afid, SubArtifactDigest: dgt, + SubArtifactRepo: repositoryName, Digest: accdgt, Type: accessorymodel.TypeSubject, }) @@ -213,6 +214,7 @@ func (suite *MiddlewareTestSuite) TestSubjectAfterAcc() { accs, err := accessory.Mgr.List(suite.Context(), &q.Query{ Keywords: map[string]interface{}{ "SubjectArtifactDigest": subArtDigest, + "SubjectArtifactRepo": name, }, }) suite.Equal(1, len(accs))