Skip to content

GithubStatusNotificationHandler: Branches[^1] throws IndexOutOfRangeException on empty Branches list #365

Description

@dnyw4l3n13

Problem

In GithubStatusNotificationHandler.BuildStatusMessage(), the code unconditionally accesses message.Branches[^1]:

Branch lastBranch = message.Branches[^1];

If the GitHub status payload arrives with an empty Branches list, this throws IndexOutOfRangeException, crashing the handler.

Location

src/BuildBot.GitHub/Publishers/GithubStatusNotificationHandler.csBuildStatusMessage method

Fix

Guard with a null/empty check, or use a safe accessor such as:

Branch? lastBranch = message.Branches.Count > 0 ? message.Branches[^1] : null;

And handle the null case gracefully in the embed title.

Discovery

Identified during code review of PR #364 (coverage task). Not introduced by that PR — pre-existing gap.

Metadata

Metadata

Assignees

Labels

AI-WorkWork for an AI AgentBlockedNeeds human input before work can continueC#C# Source Filesbuildbot-githubChanges in BuildBot.GitHub project

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions