Repository navigation
Update tracked branch heads from full scans - #479
David Larsen (dc-larsen) wants to merge 1 commit into
Conversation
PR SummaryMedium Risk Overview
Docs and Reviewed by Cursor Bugbot for commit 29b1612. Configure here. |
8cefa17 to
6a297e9
Compare
|
bugbot run |
There was a problem hiding this comment.
David Larsen (@dc-larsen), please tighten the promotion gate and verify the server behavior before including this in 2.16.0.
Use scan context to decide head eligibility
- The promotion check treats a missing PR number as a branch run. I reproduced a GitHub PR event with
--pr-number 0requesting head promotion, including when the SCM adapter selected the comparison flow. Use resolved scan context to keep PR/MR runs out of the new promotion path even when a PR number is unavailable. Add a regression test through the CLI path. - An explicit
--default-branchon a PR still requests head promotion today. Please test this case and align the code, docs, and PR body with the intended compatibility behavior. If the existing explicit behavior stays, say so and avoid the blanket promise that PR scans never request promotion. Test--no-default-branchon a tracked-branch run too. - Validate the revised build in staging for a default branch, a tracked non-default branch, an untracked branch, and the explicit opt-out. Confirm which scans update the branch head and that the tracked scan leaves the repository’s default branch intact. The current live check predates the opt-out gate.
Docs, changelog, and stack
- Suggested title: Update tracked branch heads from full scans. Keep the body focused on the behavior change, the dependency on #478, and the final validation. In code, keep one comment describing server-side eligibility. Remove the historical wording from the test comment and name the PR test for the case it covers.
- Under Changed in the shared
2.16.0changelog and in the Public Changelog block, explain the upgrade effect: “Full scans of branches that match an organization’s tracked branch patterns can update those branch heads, so findings from those branches can appear on the organization Alerts page after upgrade.” Note the--no-default-branchopt-out and explain that untracked branches are ineligible. The CLI reference should link the behavior to Settings > Alerts > Scans and clarify that--pending-headremains deprecated and has no effect. A pointer from the existing README CI guidance is enough. - Rebase and retarget this PR to
mainafter #478 lands. Keep #478’s 2.16.0 version and drop the independent 2.15.9 bump. #478’s new public flag drives the minor bump. This PR’s upgrade impact belongs in the same release notes. Rerun CI and Bugbot on the final stack.
81105de to
8cae773
Compare
6a297e9 to
b398abc
Compare
|
bugbot run |
Full scans sent set_as_pending_head=is_default_branch, so only a default-branch scan could become a head. The API also makes a scan the head of a branch that matches the organization's tracked branch patterns (Settings > Alerts > Scans), but only when the request sets set_as_pending_head, and it ignores the flag on branches it doesn't track. Python CLI scans of a tracked branch were never that branch's head, so their findings never reached the organization Alerts page. Branch runs now send set_as_pending_head=true and let the API decide. make_default_branch is unchanged. A run counts as a pull or merge request when it has a PR number, when the SCM adapter selected the comparison flow, or when the CI environment describes a PR or MR event, so a PR run with --pr-number 0 stays out of the new path. A scan marked as the default branch, including one with an explicit --default-branch on a PR, still requests it as before, and --no-default-branch keeps it off. --pending-head stays a deprecated no-op. Its warning, the CLI reference, the README and the CHANGELOG describe the new behavior. Shares the 2.16.0 version set in #478.
b398abc to
29b1612
Compare
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 29b1612. Configure here.
Stacked on #478. Review only the top commit. When #478 merges, GitHub retargets this PR to
main.Python CLI scans of a branch that matches the org's tracked branch patterns (Settings > Alerts > Scans) never become that branch's head scan, so their findings never reach the organization Alerts page. Only default-branch scans do.
Behavior change
socketcli.pysentset_as_pending_head=is_default_branch. The API makes a scan a branch's head only when the request setsset_as_pending_headand the branch is the default branch or matches a tracked pattern; it ignores the flag elsewhere.set_as_pending_head=trueand the API decides.make_default_branchis unchanged.is_pull_request_environment). Those runs don't request promotion for a non-default branch, including a GitHub PR event with--pr-number 0.--default-branchon a PR run, which keeps its existing behavior.--no-default-branch(from Check--branchand--commit-shabefore marking scan as default branch #478) never requests promotion.--pending-headstays a deprecated no-op. Its warning, the CLI reference ("Branch heads", linked to Settings > Alerts > Scans) and a README pointer describe the behavior. Shares the 2.16.0 version set in Check--branchand--commit-shabefore marking scan as default branch #478.Upgrade effect: an org that already has tracked patterns will see those branches' findings on the Alerts page once their full scans run on 2.16.0. Untracked branches are unaffected.
Testing
GITHUB_ACTORset, and withGITHUB_EVENT_NAME=pull_request/GITHUB_REF=refs/pull/1/mergeset to match CI.ruff checkclean.tests/core/test_pending_head_params.py: a tracked-branch run requests the head without becoming the default branch; a default-branch run does both; a PR scan of a non-default branch does neither; a GitHub PR event with--pr-number 0doesn't request it, through API mode and through the--scm githubcomparison flow (both fail on the previous head); explicit--default-branchon a PR still requests it;--no-default-branchrequests neither on a default or tracked branch.is_pull_request_environmenthas unit tests per CI provider.Validation
Run against production with this branch's build (b398abc; the later #478 fix only changes
--commit-shahandling, which these cases don't use), in an internal test org, on a new repository withmainas the default branch. Arelease/*org pattern was added for the test and removed afterwards.main(default branch)mainhead set (tracked_reason=default); repository default branchmainrelease/1.0(tracked)release/1.0head set (tracked_reason=pattern); default branch stillmainfeature/x(untracked)feature/x; default branch stillmainrelease/1.0 --no-default-branchrelease/1.0head unchanged (still the earlier scan); default branch stillmainHeads were read from
org_repo_branch_head_sbom_tagand the default branch from the repositories API.Public Changelog
Full scans of branches that match an organization's tracked branch patterns can update those branch heads, so findings from those branches can appear on the organization Alerts page after upgrade. Untracked branches are not eligible, pull request and merge request scans of a non-default branch don't request it, and
--no-default-branchopts a scan out.Refs: CE-529