Skip to content

feat: pass commit SHA and branch name on validation runs#208

Merged
sohankshirsagar merged 2 commits intomainfrom
sohan/pass-commitsha-branch-name-on-validation-runs
Mar 24, 2026
Merged

feat: pass commit SHA and branch name on validation runs#208
sohankshirsagar merged 2 commits intomainfrom
sohan/pass-commitsha-branch-name-on-validation-runs

Conversation

@sohankshirsagar
Copy link
Contributor

Summary

Send commit_sha and branch_name when creating validation drift runs so the backend can create a CheckCommit for tracking. Both fields are already optional on the proto — if empty, the backend skips CheckCommit creation, so this is fully backwards-compatible with older backend versions.

Changes

  • Populate CommitSha and BranchName on the validation-run request — the CreateDriftRunRequest for isValidation = true now includes both fields, resolved via getCommitSHAFromEnv() and getBranchFromEnv().
  • Extract getCommitSHAFromEnv() helper — mirrors the existing getBranchFromEnv() pattern: checks GITHUB_SHA / CI_COMMIT_SHA env vars, falls back to git rev-parse HEAD, returns empty string if nothing can be resolved.
  • Refactor validateCIMetadata — replace the inline commit SHA resolution block with a call to the new helper (DRY, no behavior change).

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="cmd/run.go">

<violation number="1" location="cmd/run.go:1019">
P2: Refactoring changes behavior: the old inline code in `validateCIMetadata` intentionally left `CommitSha` empty when CI env vars were unset, so that downstream validation would surface a clear error. The new `getCommitSHAFromEnv()` helper silently falls back to `git rev-parse HEAD`, which in GitHub Actions PR events returns the merge commit SHA (not the PR head SHA), bypassing the validation and potentially sending an incorrect commit to the backend. The `git rev-parse` fallback makes sense for the new validation-run path (best-effort), but it should not apply here in the CI metadata validation path.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="cmd/run.go">

<violation number="1" location="cmd/run.go:1125">
P2: `getCommitSHAFromEnv()` lost the git fallback, so validation runs outside recognized CI always send an empty commit SHA.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@sohankshirsagar sohankshirsagar merged commit a8f0144 into main Mar 24, 2026
14 checks passed
@sohankshirsagar sohankshirsagar deleted the sohan/pass-commitsha-branch-name-on-validation-runs branch March 24, 2026 21:22
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