Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 do not allow unsupported ListReleases to fail a run #4533

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JamieMagee
Copy link
Contributor

What kind of change does this PR introduce?

This check allows clients which currently do not support ListReleases to complete a Scorecard run. Currently azuredevopsrepo, localdir, and git do not support ListReleases. While I am working on support for Azure DevOps, I suspect that localdir and git may never support ListReleases.

What is the current behavior?

Currently, if a client does not support ListReleases, the Scorecard run fails with an error like:

Error: check runtime error: Branch-Protection: internal error: unsupported feature

This is the case for Branch-Protection and Signed-Releases.

What is the new behavior (if this is a feature change)?**

  • Tests for the changes have been added (for bug fixes/features)

Which issue(s) this PR fixes

NONE

Special notes for your reviewer

This is similar to the fix done in #4423

Does this PR introduce a user-facing change?

For user-facing changes, please add a concise, human-readable release note to
the release-note

(In particular, describe what changes users might need to make in their
application as a result of this pull request.)

Prevent unimplemented ListReleases from failing a run

@JamieMagee JamieMagee requested a review from a team as a code owner February 20, 2025 05:44
@JamieMagee JamieMagee requested review from justaugustus and spencerschrock and removed request for a team February 20, 2025 05:44
@JamieMagee JamieMagee force-pushed the jamiemagee/unsupported-list-releases branch from 191e138 to 218c95e Compare February 20, 2025 05:46
Copy link

codecov bot commented Feb 20, 2025

Codecov Report

Attention: Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Project coverage is 68.16%. Comparing base (353ed60) to head (218c95e).
Report is 124 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4533      +/-   ##
==========================================
+ Coverage   66.80%   68.16%   +1.36%     
==========================================
  Files         230      247      +17     
  Lines       16602    18641    +2039     
==========================================
+ Hits        11091    12707    +1616     
- Misses       4808     5089     +281     
- Partials      703      845     +142     

Copy link
Member

@spencerschrock spencerschrock left a comment

Choose a reason for hiding this comment

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

Generally when handling clients.ErrUnsupportedFeature, we've done so in a way to enable partial results #3832 (and linked issues / PRs). As implemented, that's not happening here.

I think your PR may be aimed at a different problem though. When you're saying "fail a run", is the exit code of 1 interfering with the AZDO pipeline task?

Comment on lines 67 to +72
// Get release branches.
releases, err := c.ListReleases()
if err != nil {
if errors.Is(err, clients.ErrUnsupportedFeature) {
return checker.BranchProtectionsData{}, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

we could still query branch protection of the default branch even if we can't determine the release branches.
Would something like this be better?:

// Get release branches.
releases, err := c.ListReleases()
if err != nil && !errors.Is(err, clients.ErrUnsupportedFeature) {
		return checker.BranchProtectionsData{}, fmt.Errorf("%w", err)
}

Comment on lines 40 to 46
releases, lerr := c.RepoClient.ListReleases()
if lerr != nil {
if errors.Is(lerr, clients.ErrUnsupportedFeature) {
return results, nil
}
return results, fmt.Errorf("RepoClient.ListReleases: %w", lerr)
}
Copy link
Member

Choose a reason for hiding this comment

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

similarly, this would prevent looking for SBOMs in source.

Comment on lines 26 to +31
func SignedReleases(c *checker.CheckRequest) (checker.SignedReleasesData, error) {
releases, err := c.RepoClient.ListReleases()
if err != nil {
if errors.Is(err, clients.ErrUnsupportedFeature) {
return checker.SignedReleasesData{}, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we should change this one. the Signed-Releases check relies on this data alone.

Copy link

github-actions bot commented Mar 3, 2025

This pull request has been marked stale because it has been open for 10 days with no activity

@github-actions github-actions bot added the Stale label Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants