Skip to content

Commit

Permalink
🧹 Avoid error messages in non error conditions for github (#4700)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaym authored Sep 27, 2024
1 parent c617e91 commit 3a91802
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions providers/github/resources/github_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,10 +1291,10 @@ func (g *mqlGithubRepository) files() ([]interface{}, error) {
ownerLogin := owner.Login.Data
_, dirContent, _, err := conn.Client().Repositories.GetContents(conn.Context(), ownerLogin, repoName, "", &github.RepositoryContentGetOptions{})
if err != nil {
log.Error().Err(err).Msg("unable to get contents list")
if strings.Contains(err.Error(), "404") {
return nil, nil
}
log.Error().Err(err).Msg("unable to get contents list")
return nil, err
}
res := []interface{}{}
Expand Down Expand Up @@ -1375,10 +1375,10 @@ func (g *mqlGithubFile) files() ([]interface{}, error) {
path := g.Path.Data
_, dirContent, _, err := conn.Client().Repositories.GetContents(conn.Context(), ownerName, repoName, path, &github.RepositoryContentGetOptions{})
if err != nil {
log.Error().Err(err).Msg("unable to get contents list")
if strings.Contains(err.Error(), "404") {
return nil, nil
}
log.Error().Err(err).Msg("unable to get contents list")
return nil, err
}
res := []interface{}{}
Expand Down Expand Up @@ -1477,10 +1477,10 @@ func (g *mqlGithubRepository) forks() ([]interface{}, error) {
for {
forks, resp, err := conn.Client().Repositories.ListForks(conn.Context(), ownerLogin, repoName, listOpts)
if err != nil {
log.Error().Err(err).Msg("unable to get contents list")
if strings.Contains(err.Error(), "404") {
return nil, nil
}
log.Error().Err(err).Msg("unable to get forks")
return nil, err
}
allForks = append(allForks, forks...)
Expand Down Expand Up @@ -1525,10 +1525,10 @@ func (g *mqlGithubRepository) stargazers() ([]interface{}, error) {
for {
stargazers, resp, err := conn.Client().Activity.ListStargazers(conn.Context(), ownerLogin, repoName, listOpts)
if err != nil {
log.Error().Err(err).Msg("unable to get contents list")
if strings.Contains(err.Error(), "404") {
return nil, nil
}
log.Error().Err(err).Msg("unable to get stargazers")
return nil, err
}
allStargazers = append(allStargazers, stargazers...)
Expand Down Expand Up @@ -1596,10 +1596,10 @@ func (g *mqlGithubRepository) getIssues(state string) ([]interface{}, error) {
for {
issues, resp, err := conn.Client().Issues.ListByRepo(conn.Context(), ownerLogin, repoName, listOpts)
if err != nil {
log.Error().Err(err).Msg("unable to get contents list")
if strings.Contains(err.Error(), "404") {
return nil, nil
}
log.Error().Err(err).Msg("unable to get issues")
return nil, err
}
allIssues = append(allIssues, issues...)
Expand Down

0 comments on commit 3a91802

Please sign in to comment.