Skip to content

Conversation

@Bencheng21
Copy link
Contributor

ref githubv2 doc
image

We need to skip the PermissionDenied error during sync.
There are some places where Forbidden error is ignored. See here

However, @btipling says it's a scary feature, since it would churn data if the permission get deleted accidentally when it's shouldn't be.

We could discuss more on that.

Test.

Before changes.

c.method":"ListGrants","peer.address":"127.0.0.1:62857","error":"error: listing grants for resource repository/993471239 failed: github-connector: failed to list repos: GET https://api.github.com/repos/laurenTestC1Org/test-BB761-private/teams: 403 Resource not accessible by personal access token []","grpc.code":"Unknown","grpc.time_ms":141.894}
{"level":"error","ts":1748646013.277557,"caller":"ratelimit/grpc.go:134","msg":"ratelimit: error running client request","error":"rpc error: code = Unknown desc = error: listing grants for resource repository/993471239 failed: github-connector: failed to list repos: GET https://api.github.com/repos/laurenTestC1Org/test-BB761-private/teams: 403 Resource not accessible by personal access token []"}
{"level":"error","ts":1748646013.285064,"caller":"connectorrunner/runner.go:204","msg":"runner: error processing on-demand task","error":"runner: error processing task: rpc error: code = Unknown desc = error: listing grants for resource repository/993471239 failed: github-connector: failed to list repos: GET https://api.github.com/repos/laurenTestC1Org/test-BB761-private/teams: 403 Resource not accessible by personal access token []","task_id":"","task_type":"sync_full"}
{"level":"error","ts":1748646013.285162,"caller":"cli/commands.go:291","msg":"error running connector","error":"runner: error processing task: rpc error: code = Unknown desc = error: listing grants for resource repository/993471239 failed: github-connector: failed to list repos: GET https://api.github.com/repos/laurenTestC1Org/test-BB761-private/teams: 403 Resource not accessible by personal access token []"}
runner: error processing task: rpc error: code = Unknown desc = error: listing grants for resource repository/993471239 failed: github-connector: failed to list repos: GET https://api.github.com/repos/laurenTestC1Org/test-BB761-private/teams: 403 Resource not accessible by personal access token []

After changes.
image

@Bencheng21 Bencheng21 requested a review from laurenleach May 30, 2025 23:01
if err != nil {
if resp.StatusCode == http.StatusForbidden {
l.Warn("insufficient access to list teams", zap.String("repository", resource.DisplayName))
return nil, "", nil, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't return empty string for the next page token, if someone has permissions to list repository collaborators but not list repository teams, we are going to skip those grants. instead you can do

err = bag.Next("")
if err != nil {
	return nil, "", nil, err
}
pageToken, err := bag.Marshal()
if err != nil {
	return nil, "", nil, err
}
return nil, pageToken, nil, nil

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks.

@Bencheng21 Bencheng21 requested a review from laurenleach June 2, 2025 20:17
@Bencheng21 Bencheng21 merged commit d508c03 into main Jun 3, 2025
2 checks passed
@Bencheng21 Bencheng21 deleted the BB761 branch June 3, 2025 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants