Skip to content

Conversation

@Mic92
Copy link
Member

@Mic92 Mic92 commented Oct 28, 2025

Fixes #522 where buildbot-master fails to start with AttributeError when sourcestamp has an explicit None branch value. dict.get() only uses the default when the key is missing, not when the value is None.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of builds with missing branch information to prevent potential errors.

Fixes #522 where buildbot-master fails to start with AttributeError
when sourcestamp has an explicit None branch value. dict.get() only
uses the default when the key is missing, not when the value is None.
@coderabbitai
Copy link

coderabbitai bot commented Oct 28, 2025

Walkthrough

Modified branch_key_for_pr in build_canceller.py to coerce None branch values to empty strings using the pattern build.get("branch") or "" instead of build.get("branch", ""). This prevents AttributeError when branch is None and .startswith() is called.

Changes

Cohort / File(s) Change Summary
Branch None handling fix
buildbot_nix/buildbot_nix/build_canceller.py
Updated branch retrieval to safely coerce None values to empty string, preventing AttributeError when calling .startswith() on a None branch during build cancellation logic

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5–10 minutes

  • Focus areas:
    • Verify that coercing None to "" does not alter the intended behavior of PR branch detection (refs/pull/*, refs/merge-requests/*)
    • Confirm that the fix addresses all code paths where branch may be None without introducing new edge cases
    • Check for any other locations in the codebase that may have similar None-handling vulnerabilities

Possibly related PRs

  • Cancel old builds #501: Introduced the branch_key_for_pr function that is being modified in this PR to handle None branch values safely.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning The PR addresses the core crash fix specified in issue #522 by updating branch retrieval logic to handle None values, preventing the AttributeError when branch.startswith() is called on None. However, linked issue #522 explicitly requires regression tests covering sourcestamp.branch == None and PR ref patterns (refs/pull/, refs/merge-requests/), which are not shown in the provided changeset summary. While the immediate crash is fixed, the absence of regression tests means the PR does not fully satisfy all coding-related requirements from the linked issue. Add regression tests that specifically cover the case where sourcestamp.branch is None, as well as branch values that match PR reference patterns. This will prevent future regressions and verify that the fix handles all edge cases mentioned in issue #522. Include tests in the changeset to demonstrate that the fix works correctly and that canceller behavior is not affected.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "fix: handle None branch in build_canceller" is clear, concise, and directly related to the main change in the changeset. It accurately summarizes the primary modification—handling None values for the branch field in the build_canceller module—in a way that a teammate scanning the commit history would immediately understand the purpose of the change.
Out of Scope Changes Check ✅ Passed The changeset modifies only buildbot_nix/buildbot_nix/build_canceller.py to handle None branch values, which is directly aligned with the PR objective of fixing the startup crash from issue #522. The change is narrowly scoped to the specific function that was failing (branch_key_for_pr) and does not introduce unrelated modifications or changes to other areas of the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-buildbot-canceler

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Mic92 Mic92 enabled auto-merge October 28, 2025 08:41
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 01dfc9a and 3ba0717.

📒 Files selected for processing (1)
  • buildbot_nix/buildbot_nix/build_canceller.py (1 hunks)

@Mic92 Mic92 added this pull request to the merge queue Oct 28, 2025
Merged via the queue into main with commit 3cd0114 Oct 28, 2025
4 checks passed
@Mic92 Mic92 deleted the fix-buildbot-canceler branch October 28, 2025 08:44
Sign up for free to 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.

unknown error, while starting buildbot-master

2 participants