Skip to content

Bug: Sandbox Copy-Report Names a Nonexistent master Branch on Deployed Previews #2871

Description

@cjpillsbury

The sandbox's copy-report action exists to tell a triager which build produced a problem. On every deployed sandbox it names a branch that does not exist, so that line points nowhere.

Impact

buildReport assembles the block a reporter pastes into an issue:

## Video.js sandbox preview
- URL: …
- Version: …
- Build: master @ db1d097
- Selection: …

master is not a branch of this repository — the default branch is main. Anyone acting on a pasted report has to know to ignore that field.

The commit is unaffected and always correct, so a report is still traceable; the branch is the part that misleads. Local runs are unaffected, which is why it does not show up in development.

Reproduction

  1. Open any deployed sandbox — production at https://v10-sandbox-git-main-mux.vercel.app or a PR preview.
  2. Copy the preview report from the toolbar.
  3. The - Build: line reads master @ <commit>.

Observed on production at commit db1d097 (fix(hlsjs-video): route legacy hls mime types to hls.js, #2866), which is a real ancestor of main. git ls-remote --heads origin master returns nothing.

Cause

apps/sandbox/vite.config.ts reads the branch from the local checkout at build time:

__SANDBOX_BRANCH__: JSON.stringify(describeGit('rev-parse', '--abbrev-ref', 'HEAD')),

Vercel's build container checks out the deployed commit but does not preserve the branch name, so rev-parse --abbrev-ref HEAD answers master whatever was deployed. The unknown/HEAD fallbacks in the consumer never fire, because master looks like a real answer.

Resolving it

Vercel's own environment variables name the real branch and commit, with describeGit still covering local builds and checkouts with no git metadata, as on StackBlitz:

__SANDBOX_BRANCH__: JSON.stringify(
  process.env.VERCEL_GIT_COMMIT_REF || describeGit('rev-parse', '--abbrev-ref', 'HEAD')
),

Verified on a preview deploy: the report changed from master @ … to spike/remotion-media @ ….

VERCEL_GIT_COMMIT_SHA is available for the commit too, but is not needed — describeGit already answers that correctly, since Vercel checks out the real commit.

Acceptance criteria

  • A report copied from a deployed sandbox names the branch that was deployed.
  • A report copied from a local run still names the local branch.
  • A checkout with no git metadata still produces a report rather than failing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions