aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
162 stars 55 forks source link

Deployment: reference is not a tree <commit-id> #1877

Open hongthach12 opened 1 month ago

hongthach12 commented 1 month ago

Environment information

2024-08-16T04:26:30.807Z [INFO]: # Switching to commit: bebb03861c310222ecde1095d965c47d02e3d15
2024-08-16T04:26:30.824Z [INFO]: fatal: reference is not a tree: bebb03861c310222ecde1095d965c47d02e3d154

2024-08-16T04:26:30.926Z [INFO]: Successfully cleaned up Git credentials

2024-08-16T04:26:30.927Z [ERROR]: !!! CustomerError: Unable to clone repository due to user error code: 128

2024-08-16T04:26:30.927Z [INFO]: # Starting environment caching...
2024-08-16T04:26:30.928Z [INFO]: # Environment caching completed

Description

This issue happend when i merged 2 PRs on 2 repository (App1, App2) in the same time on Amplify will be trigger deploy App1, App2 pending deploy. after App1 deploy finished , App2 start deploy, but on App2 using commitId of repository of App1 , I don't know why App2 using commit of repository of App1.

to fix it, i need to force push / or recreate branch of repository of app 2.

i thinks this issue of Amplify Deployment

Jay2113 commented 1 month ago

Hi @hongthach12 👋 , thanks for reaching out. Can you share the Amplify app ids for both apps? Are you observing this build error for web preview or PR builds?

hongthach12 commented 1 month ago

hi @Jay2113

Are you observing this build error for web preview or PR builds

this is build error for web

Can you share the Amplify app ids for both apps

App1: dsucf46bvwx38 App2: dgt3krpq2jhoh

Jay2113 commented 1 month ago

@hongthach12 This build error can occur when Git tries to access a commit that no longer exists or was never created. This can happen due to force pushes, rebases, incorrect references in build configuration file amplify.yml, or repository corruption. It typically arises from changes in the Git history or inconsistencies in the remote repository.

Additionally, you can try clearing the build cache in the amplify.yml file:

frontend:
  phases:
    preBuild:
      commands:
        - rm -rf node_modules
        - npm install

I see that your latest build (Build 21 for app dgt3krpq2jhoh) has succeeded. Thus, are you unblocked?

hongthach12 commented 1 month ago

@Jay2113 no,

i have check commit bebb03861c310222ecde1095d965c47d02e3d15, it's already exists on other repository (App1)

Jay2113 commented 3 weeks ago

@hongthach12 I looked at the app ids and each of them are connected to a different repository. Can you elaborate on your workflow? Is it the following?

App ID: dsucf46bvwx38 -> Repository 1 > PR A > Commit ID: abcdef
App ID: dgt3krpq2jhoh -> Repository 2 > PR B > Commit ID: ghijklm

- Open a distinct PR against both repositories
- PR A is merged on repository 1 - Build is successful
- PR B is merged on repository 2 - Build fails since it uses commit id: abcdef which is for repository 1?
hongthach12 commented 3 weeks ago

yes exactly @Jay2113

hongthach12 commented 1 week ago

hi @Jay2113

Can you help to check:

Repo1 -> link to App1 (appId: dsucf46bvwx38) Repo2 -> link to App2 (appId: dgt3krpq2jhoh)

now, i got other issue

when i merge code on Repo1 --> Build App 1

BUT

App 2 build too with commit of Repo 1