Skip to content

fix(xtest): Lets push-to-main SHA resolve bare HEAD right - #533

Merged
dmihalcik-virtru merged 1 commit into
mainfrom
fix-push-main-head
Jun 23, 2026
Merged

fix(xtest): Lets push-to-main SHA resolve bare HEAD right#533
dmihalcik-virtru merged 1 commit into
mainfrom
fix-push-main-head

Conversation

@dmihalcik-virtru

@dmihalcik-virtru dmihalcik-virtru commented Jun 23, 2026

Copy link
Copy Markdown
Member

Problem

Follow-up to #532. xtest still fails during go CLI setup, now on push-to-main events from opentdf/platform, as in this example failure:

FileNotFoundError: SDK executable not found at path: sdk/go/dist/HEAD/cli.sh

The matrix value was go@HEAD and only main got built.

Root cause

The platform caller passes the go ref as the main-tip commit SHA (otdfctl-ref: <sha> main). On a push to main, git ls-remote lists that SHA under two refs:

<sha>	HEAD
<sha>	refs/heads/main

_ref_specificity scored every non-PR/non-merge-queue ref equally (2), so min() kept the first entry — the symbolic HEAD. That fell through _classify_sha_match to the generic tag path, producing tag = "HEAD" with no head flag. So setup-cli-tool skipped the source build (only main, separately resolved as a head, was built) and the test looked for the non-existent dist/HEAD/cli.sh.

Fix

Rank real refs above the bare HEAD: PR > merge-queue > branch > tag > other. Now refs/heads/main wins over HEAD, giving tag = "main", head = true (built from source).

Branch is deliberately ranked above tag: the SHA path always resolves a commit-under-test, and only the branch case sets head=true. So a commit that is simultaneously a branch tip and a release tag (e.g. right after release-please) still gets a source build rather than resolving to a tag that wouldn't be built.

Testing

  • Added test_head_and_branch_prefers_branch and test_branch_preferred_over_tag.
  • uv run pytest — 137 pass.
  • uv run ruff check ., uv run ruff format ., uv run pyright — clean.

On a push to main the tip SHA is listed by ls-remote as both the
symbolic HEAD and refs/heads/main. With equal specificity, min() picked
the first (HEAD), yielding tag=HEAD with no head flag — so nothing built
and the test looked for dist/HEAD/cli.sh.

Rank real refs (pull > merge-queue > branch > tag) above the bare HEAD
so refs/heads/main wins, giving tag=main, head=true. Branch is ranked
above tag so a commit-under-test that is also a release tag still gets a
source build.
@dmihalcik-virtru
dmihalcik-virtru requested review from a team as code owners June 23, 2026 14:18
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@dmihalcik-virtru, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 53 minutes and 57 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a5cff1b2-8d4c-4055-b5b8-ef41260ddc24

📥 Commits

Reviewing files that changed from the base of the PR and between 5bf87b0 and 5f726d0.

📒 Files selected for processing (2)
  • otdf-sdk-mgr/src/otdf_sdk_mgr/resolve.py
  • otdf-sdk-mgr/tests/test_resolve.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-push-main-head

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refines the reference resolution logic in _ref_specificity to prioritize branches over tags and other symbolic references (like HEAD) when they share the same SHA. This ensures that a branch is preferred so that it is correctly flagged as a head and built from source. Additionally, unit tests have been added to verify that branches are preferred over symbolic HEADs and tags. There are no review comments to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@dmihalcik-virtru dmihalcik-virtru changed the title Fix push-to-main SHA resolving to bare HEAD instead of main fix(xtest): Lets push-to-main SHA resolve bare HEAD right Jun 23, 2026
@dmihalcik-virtru
dmihalcik-virtru merged commit bf03d8b into main Jun 23, 2026
20 of 21 checks passed
@dmihalcik-virtru
dmihalcik-virtru deleted the fix-push-main-head branch June 23, 2026 15:54
@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants