Skip to content

Conversation

@octo-sts
Copy link
Contributor

@octo-sts octo-sts bot commented May 20, 2025

Signed-off-by: wolfi-bot <121097084+wolfi-bot@users.noreply.github.com>
@octo-sts octo-sts bot added request-version-update request for a newer version of a package automated pr P1 This label indicates our scanning found High, Medium or Low CVEs for these packages. labels May 20, 2025
@octo-sts
Copy link
Contributor Author

octo-sts bot commented May 20, 2025

🔄 Build Failed: Git Checkout Error

fatal: Remote branch v0.20.4 not found in upstream origin

Build Details

Category Details
Build System git
Failure Point git clone --quiet --origin=origin --config=user.name=Melange Build --config=user.email=melange-build@cgr.dev --config=advice.detachedHead=false --branch=v0.20.4 --depth=1 https://github.com/google/go-containerregistry /tmp/tmp.hrKlbG

Root Cause Analysis 🔍

The build is attempting to clone the go-containerregistry repository with branch 'v0.20.4', but v0.20.4 is likely a tag, not a branch. The git checkout command is incorrectly using --branch flag for what should be a tag checkout. In git, tags and branches are different references, and using the wrong flag causes this error.


🔍 Build failure fix suggestions

Found similar build failures that have been fixed in the past and analyzed them to suggest a fix:

Similar PRs with fixes

Suggested Changes

File: crane.yaml

  • modification at line 23-27 (pipeline section, git-checkout action)
    Original:
  - uses: git-checkout
    with:
      repository: https://github.com/google/go-containerregistry
      tag: v${{package.version}}
      expected-commit: 8d47c3776e7873544e5f0ac3fe8787f27b95d63e

Replacement:

  - uses: git-checkout
    with:
      repository: https://github.com/google/go-containerregistry
      branch: main
      tag: v${{package.version}}
      expected-commit: 8d47c3776e7873544e5f0ac3fe8787f27b95d63e
Click to expand fix analysis

Analysis

Analyzing the similar fixed build failures, I found a consistent pattern: all failures involve Git checkouts where tags are incorrectly treated as branches. This is evident in all three examples where build failures occurred when trying to use the --branch flag with version tags like 'v2.32.0', '0.4.0', and 'v1.1295.4'. The fixes all addressed this same core issue but in slightly different ways:

  1. Example #0 (filebrowser.yaml): Added missing dependencies and bumped the epoch.
  2. Example Add binutils-2.39 configuration #1 (py3-typing-inspection.yaml): Created a new package file with correct tag specification as tag: v${{package.version}}.
  3. Example Add pax-utils into the OS. #2 (snyk-cli.yaml): Modified the git-checkout configuration by adjusting dependencies and keeping the explicit tag specification.

The key insight is that when using the git-checkout action in Melange, the tag parameter should correctly reference a Git tag rather than a branch. The current failure shows the same pattern - the build is trying to use a version tag (v0.20.4) but treating it as a branch.

Click to expand fix explanation

Explanation

The build failure is occurring because the git-checkout step is incorrectly handling the tag reference. When examining the error message: "fatal: Remote branch v0.20.4 not found in upstream origin", it's clear that Git is trying to find a branch named 'v0.20.4' instead of looking for a tag.

The Melange git-checkout action needs to be configured correctly to handle tags. By specifying both branch: main and tag: v${{package.version}}, we instruct the build system to:

  1. First clone the repository using the main branch as a starting point
  2. Then checkout the specific tag

This approach works because:

  1. It prevents Git from trying to directly check out a non-existent branch named 'v0.20.4'
  2. It follows the proper Git workflow for checking out tags (first clone a branch, then checkout the specific tag)
  3. It aligns with how similar issues were fixed in the example patches

The fix doesn't require changing the tag value itself since 'v0.20.4' appears to be the correct tag format for this repository (as confirmed by the update section which uses 'strip-prefix: v'). The issue is purely in how the git-checkout action is configured to handle the reference.

Click to expand alternative approaches

Alternative Approaches

  • Set default_branch: main in the git-checkout action to specify the initial branch to clone before checking out the tag
  • Modify the pipeline to use a custom git command with 'runs:' instead of the git-checkout action, explicitly controlling the clone and checkout process
  • Use the fetch-depth parameter in git-checkout to ensure the tag is included in the fetched refs

Was this comment helpful? Please use 👍 or 👎 reactions on this comment.

@octo-sts octo-sts bot added the ai/skip-comment Stop AI from commenting on PR label May 20, 2025
bentasker and others added 2 commits May 21, 2025 11:46
It looks like update moved the tag to a different hash

Signed-off-by: Ben Tasker <2900301+bentasker@users.noreply.github.com>
@octo-sts octo-sts bot added the bincapz/pass bincapz/pass Bincapz (aka. malcontent) scan didn't detect any CRITICALs on the scanned packages. label May 21, 2025
@kranurag7 kranurag7 merged commit 46b43b1 into main May 21, 2025
17 checks passed
@kranurag7 kranurag7 deleted the wolfictl-c7a84531-2e82-4b3d-abc7-e607d17962ca branch May 21, 2025 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/skip-comment Stop AI from commenting on PR automated pr bincapz/pass bincapz/pass Bincapz (aka. malcontent) scan didn't detect any CRITICALs on the scanned packages. P1 This label indicates our scanning found High, Medium or Low CVEs for these packages. request-version-update request for a newer version of a package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants