fix(github): don't abort scorecard run on 422 from commit search - #5181
Open
pujitha24 wants to merge 3 commits into
Open
fix(github): don't abort scorecard run on 422 from commit search#5181pujitha24 wants to merge 3 commits into
pujitha24 wants to merge 3 commits into
Conversation
Motivation: The Dependency-Update-Tool check calls GitHub's commit search API to look for dependabot[bot] commits. Some public repositories that GitHub search hasn't indexed yet, and GitHub Enterprise Server instances, return 422 Validation Failed for this otherwise-valid query. That 422 was propagated as a hard error, aborting the entire scorecard run with "check runtime error: Dependency-Update-Tool: internal error: dependabot commit search: ..." even though every other check had already finished successfully. Approach: searchCommitsHandler.search now detects a 422 Unprocessable Entity response from Search.Commits and returns an empty commit list with no error, instead of a hard error. This mirrors the existing handling of clients.ErrUnsupportedFeature a few lines away in checks/raw/dependency_update_tool.go, which already treats "can't search commits" as "assume no commit-search-based tools were found" rather than failing the whole run. Also fixed an unrelated copy-paste typo in the wrapped error message (Search.Code -> Search.Commits, since this call is Search.Commits). This only changes error handling for this specific HTTP status code; check results for repos that don't hit the 422 are unchanged. For repos that do hit it, Dependency-Update-Tool now completes (falling back to file-based detection) instead of aborting the whole run. Validation: Added TestSearchCommitsHandles422, which mocks a 422 HTTP response and asserts search() returns no error and zero commits. Confirmed this test fails on the pre-fix code (reproducing the reported "Search.Code: 422 Validation Failed" error) and passes after the fix. Ran: go build ./... SKIP_GINKGO=1 go test -race ./clients/githubrepo/... ./checks/raw/... golangci-lint run -c .golangci.yml --new-from-rev=HEAD ./clients/githubrepo/... All passed with no new lint issues. Report: ossf#4352 Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
pujitha24
had a problem deploying
to
integration-test
August 14, 2026 08:36 — with
GitHub Actions
Failure
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5181 +/- ##
==========================================
+ Coverage 66.80% 70.15% +3.34%
==========================================
Files 230 252 +22
Lines 16602 15865 -737
==========================================
+ Hits 11091 11130 +39
+ Misses 4808 3848 -960
- Partials 703 887 +184 🚀 New features to boost your workflow:
|
Move the "treat GitHub commit-search 422 as no data" handling out of searchCommitsHandler.search and into checks/raw/dependency_update_tool.go, mirroring the existing clients.ErrUnsupportedFeature handling there. The previous version swallowed the 422 at the generic client layer, which also silently hid genuinely invalid search queries (e.g. a nonexistent author) and broke e2e/searchCommits_test.go's "Should return error as the user does not exist" case. SearchCommits now still returns an error (wrapped in the new clients.ErrCommitSearchUnprocessable sentinel) for 422s, and only the dependency-update-tool check - the one issue ossf#4352 is actually about - treats that specific error as "assume no dependabot commits found" instead of aborting. Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
pujitha24
temporarily deployed
to
integration-test
August 14, 2026 09:49 — with
GitHub Actions
Inactive
pujitha24
temporarily deployed
to
integration-test
August 15, 2026 09:45 — with
GitHub Actions
Inactive
Contributor
Author
|
Just checking in on this one — it's rebased on main and all checks are green. Happy to make any changes if something would help move review along. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Bug fix.
What is the current behavior?
The
Dependency-Update-Toolcheck calls GitHub's commit search API to look fordependabot[bot]commits. Some public repositories (not yet indexed by GitHubsearch) and GitHub Enterprise Server instances return
422 Validation Failedfor this otherwise-valid query. That 422 is currently propagated as a hard
error, which aborts the entire scorecard run with
check runtime error: Dependency-Update-Tool: internal error: dependabot commit search: ..., eventhough every other check already finished successfully.
What is the new behavior (if this is a feature change)?
searchCommitsHandler.searchnow detects a422 Unprocessable Entityresponse from
Search.Commitsand returns an empty commit list with noerror, instead of a hard error. This mirrors the existing handling of
clients.ErrUnsupportedFeaturea few lines away inchecks/raw/dependency_update_tool.go, which already treats "can't searchcommits" as "assume no commit-search-based tools were found" rather than
failing the whole run. Also fixed an unrelated copy-paste typo in the wrapped
error message (
Search.Code->Search.Commits, since this call isSearch.Commits).Which issue(s) this PR fixes
NONE
Special notes for your reviewer
Validation: added
TestSearchCommitsHandles422, which mocks a 422 HTTPresponse and asserts
search()returns no error and zero commits. Confirmedthis test fails on the pre-fix code (reproducing the reported
"Search.Code: 422 Validation Failed"error) and passes after the fix.Commands run:
go build ./...SKIP_GINKGO=1 go test -race ./clients/githubrepo/... ./checks/raw/...(matches CI'smake unit-test)golangci-lint run -c .golangci.yml --new-from-rev=HEAD ./clients/githubrepo/...(0 new issues)This only changes the client's error handling for a specific HTTP status
code; user-visible check results for repos that don't hit this 422 are
unchanged. For repos that do hit it,
Dependency-Update-Toolwill nowcomplete (falling back to file-based detection, e.g.
.github/dependabot.yml)instead of aborting the whole scorecard run.
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.)
Fixes #4352