@@ -297,18 +297,25 @@ func GetPullRequestReviewComments(ctx context.Context, client *github.Client, ca
297297 if cache == nil {
298298 return nil , fmt .Errorf ("lockdown cache is not configured" )
299299 }
300- if len (comments ) > 0 {
301- login := comments [0 ].GetUser ().GetLogin ()
302- if login != "" {
303- isPrivate , hasPushAccess , err := cache .GetRepoAccessInfo (ctx , login , owner , repo )
304- if err != nil {
305- return nil , fmt .Errorf ("failed to check content removal: %w" , err )
306- }
307- if ! isPrivate && ! hasPushAccess {
308- return mcp .NewToolResultError ("access to pull request review comments is restricted by lockdown mode" ), nil
309- }
300+ filteredComments := make ([]* github.PullRequestComment , 0 , len (comments ))
301+ for _ , comment := range comments {
302+ user := comment .GetUser ()
303+ if user == nil {
304+ continue
305+ }
306+ isPrivate , hasPushAccess , err := cache .GetRepoAccessInfo (ctx , user .GetLogin (), owner , repo )
307+ if err != nil {
308+ return mcp .NewToolResultError (fmt .Sprintf ("failed to check lockdown mode: %v" , err )), nil
309+ }
310+ if isPrivate {
311+ filteredComments = comments
312+ break
313+ }
314+ if hasPushAccess {
315+ filteredComments = append (filteredComments , comment )
310316 }
311317 }
318+ comments = filteredComments
312319 }
313320
314321 r , err := json .Marshal (comments )
@@ -342,16 +349,21 @@ func GetPullRequestReviews(ctx context.Context, client *github.Client, cache *lo
342349 if cache == nil {
343350 return nil , fmt .Errorf ("lockdown cache is not configured" )
344351 }
345- if len (reviews ) > 0 {
346- login := reviews [0 ].GetUser ().GetLogin ()
352+ filteredReviews := make ([]* github.PullRequestReview , 0 , len (reviews ))
353+ for _ , review := range reviews {
354+ login := review .GetUser ().GetLogin ()
347355 if login != "" {
348356 isPrivate , hasPushAccess , err := cache .GetRepoAccessInfo (ctx , login , owner , repo )
349357 if err != nil {
350- return nil , fmt .Errorf ("failed to check content removal: %w" , err )
358+ return nil , fmt .Errorf ("failed to check lockdown mode: %w" , err )
359+ }
360+ if isPrivate {
361+ filteredReviews = reviews
351362 }
352- if ! isPrivate && ! hasPushAccess {
353- return mcp . NewToolResultError ( "access to pull request reviews is restricted by lockdown mode" ), nil
363+ if hasPushAccess {
364+ filteredReviews = append ( filteredReviews , review )
354365 }
366+ reviews = filteredReviews
355367 }
356368 }
357369 }
0 commit comments