Skip to content

fix(dependency_updater): guard against index out of range when branchCommit is empty - #1162

Open
ygd58 wants to merge 2 commits into
base:mainfrom
ygd58:fix/dependency-updater-bounds-check
Open

fix(dependency_updater): guard against index out of range when branchCommit is empty#1162
ygd58 wants to merge 2 commits into
base:mainfrom
ygd58:fix/dependency-updater-bounds-check

Conversation

@ygd58

Copy link
Copy Markdown

Fixes the issue opened above.

In getVersionAndCommit(), branchCommit[0].SHA is accessed directly without checking if the GitHub API returned any commits. If the branch exists but has no commits, or if the API returns an empty list, this panics with index out of range.

Added a len(branchCommit) == 0 check that returns a descriptive error naming the branch and repo instead of panicking.

@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

RequirementStatusMore Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot0
1 if user is external0
2 if repo is sensitive0
From .codeflow.yml1
Additional review requirements
Show calculation
Max0
0
From CODEOWNERS0
Global minimum0
Max 1
1
1 if commit is unverified0
Sum1

@ygd58

Copy link
Copy Markdown
Author

hey @meyer9@danyalprout can you take a look? guards against an index out of range panic when the GitHub API returns zero commits for a branch in the dependency updater.

Sign up for freeto 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.

2 participants

@ygd58@cb-heimdall