Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] !!! CustomerError: : Invalid Monorepo spec provided. The "appRoot" key needs to be a string #3900

Closed
3 tasks done
ullattil opened this issue Jan 17, 2024 · 11 comments
Closed
3 tasks done
Labels
archived This issue has been locked. closed-for-staleness

Comments

@ullattil
Copy link

Before opening, please confirm:

Amplify Hosting feature

Backend builds, Monorepo

Is your feature request related to a problem? Please describe:

I had a working app during the last commit. The new commit does not add any code or change any files except for logs (app and src remain untouched). Now every time I try to build the app I get a [ERROR]: !!! CustomerError: Invalid Monorepo spec provided. The "appRoot" key needs to be a string.
Along with an error that states "There was an issue connecting to your repo provider, click "Reconnect repository" in General Settings, and then try your build again."

Even though this was never an issue in the previous 34 successful builds of the same app. I haven't modified the build setting or any other feature within the studio in the time since my last commit. Neither have I changed anything in the source code. It doesn't not make sense to me. I have tried surrounding the appRoot key with quotation marks, yet the issue persists. I have also tried using an older branch containing an old version of the app that worked and that too failed. I have also tried building the app on the last working commit and that was also unsuccessful and gave the same error. In short, Nothing was changed but now I can't build any new versions of the same app, despite having the exact same code and settings on the console.

The old deployed version of the app is still accessible on the internet and works just as intended when the last commit was deployed.

Screenshot 2024-01-16 at 7 37 27 PM

I have also correctly set the environment variables according to the provided documentation. I also don't have a amplify.yml file in the repo, although I already tried to include it in the repo to see if it solved the problem but it didn't.

Describe how you'd like this feature to work

I hope this isn't a small oversight on my part. I am raising this issue to see if there is any way I can solve the issue without having to build the entire backend of the app using amplify again. I believe that this is a bug and the error messages might be misleading as the app was build without errors using the same code and build settings a few weeks earlier.

@ullattil ullattil added the feature-request New feature or request label Jan 17, 2024
Copy link

This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!

@dontic
Copy link

dontic commented Jan 18, 2024

@ullattil I'm having the same exact issue when deploying a new version of an app today. Changes were only text modification in an Astro build, nothing major.

Was working fine before and I also did not make changes to any config or such.

It's also really confusing to get two, completely unrelated, error messages as you said:

Invalid Monorepo spec provided. The "appRoot" key needs to be a string

and

There was an issue connecting to your repo provider, click "Reconnect repository" in General Settings, and then try your build again.

I tried reconnecting the repo but that did not work.

@victorccccc
Copy link
Contributor

victorccccc commented Jan 18, 2024

Hi 👋 , could you please provide the AppId and also the buildSpec you are using to build your application? Thanks

Note: We will use buildSpec in amplify.yml in your repository if it exists otherwise the one in AWS Amplify console will be used

@dontic
Copy link

dontic commented Jan 19, 2024

Ok so I spoke with Jay in the AWS Amplify discord and he solved the issue for me, in case it helps @ullattil

We initially had the frontend and backend together and, even though the backend has always been deployed separatelly, because the frontend lived under the frontend directory in the repo, I had to set up the app root with an empty backend:

version: 1
applications:
  - frontend:
      phases:
        preBuild:
          commands:
            - npm ci
        build:
          commands:
            - npm run build
            - mv node_modules ./.amplify-hosting/compute/default
      artifacts:
        baseDirectory: .amplify-hosting
        files:
          - '**/*'
      cache:
        paths:
          - node_modules/**/*
    appRoot: frontend
  - backend:
      phases:
        build:
          commands:
            - amplifyPush --simple

We've recently moved the backend and frontend separately, so I modified the app root a couple of weeks ago:

...
    appRoot: .
...

Jay said that "We recently added a check which validates if this attribute within the buildSpec is accurate and if not the build would fail." And thus the reason for the error we began experiencing.

I solved it by changing my build spec and removing the backend and appRoot completely:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
        - mv node_modules ./.amplify-hosting/compute/default
  artifacts:
    baseDirectory: .amplify-hosting
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

@martin-stefan
Copy link

I am having the same issue and it is not yet resolved even after removing the app root and backend from the yml file.

@radmed0106
Copy link

radmed0106 commented Jan 21, 2024

I tried all the solutions on the previous comments without any success. After reviewing the AWS Amplify hosting documentation again (https://docs.aws.amazon.com/amplify/latest/userguide/monorepo-configuration.html) I modified the syntax of my amplify.yml file and this solved the bug. Basically, for monorepo aplications, the appRoot becomes the main node that encapsulates the environments like this:

version: 1
applications:
  - appRoot: apps/react-app
    backend:
      phases:
        build:
          commands:
            - enter command
    frontend:
      phases:
        build:
          commands:
            - enter command

@Narrator
Copy link
Contributor

@martin-stefan Can you please share your build spec?

@martin-stefan
Copy link

This is what it looked like before removing appRoot. The structure of my monorepo is:

monorepo
    frontend
        frontendReactApp
        awsLambdaBackend

yml file:

applications:
  
  - frontend:
      phases:
        preBuild:
          commands:
            - npm ci
        build:
          commands:
            - npm run build
      artifacts:
        baseDirectory: build
        files:
          - '**/*'
      cache:
        paths:
          - node_modules/**/*
    appRoot: frontend
    
  - backend:
      phases:
        build:
          commands:
           - npm i -g @aws-amplify/cli
           - amplifyPush --simple

My environment variable looks like:
AMPLIFY_MONOREPO_APP_ROOT | frontend

@ullattil
Copy link
Author

I tried all the solutions on the previous comments without any success. After reviewing the AWS Amplify hosting documentation again (https://docs.aws.amazon.com/amplify/latest/userguide/monorepo-configuration.html) I modified the syntax of my amplify.yml file and this solved the bug. Basically, for monorepo aplications, the appRoot becomes the main node that encapsulates the environments like this:

version: 1 applications:   - appRoot: apps/react-app     backend:       phases:         build:           commands:             - enter command     frontend:       phases:         build:           commands:             - enter command

I tried this and it finally fixed the issue I had, Thanks a lot for every ones contribution, I will keep this issue open for another week in case someone else is also migrating to the new format.

@martin-stefan
Copy link

martin-stefan commented Jan 24, 2024

I was able to fix this issue by changing my yml from:

applications:
  - frontend: ...
    appRoot: frontend
  - backend: ...

to:

applications:
  - appRoot: frontend
    frontend: ...
    backend: ...

where frontend is the root of my monorepo

@Jay2113 Jay2113 added closing-soon This issue will automatically close in 4 days unless further comments are made. and removed feature-request New feature or request labels Jan 24, 2024
@github-actions github-actions bot added closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jan 28, 2024
Copy link

This issue has been automatically locked.

@github-actions github-actions bot added the archived This issue has been locked. label Jan 28, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. closed-for-staleness
Projects
None yet
Development

No branches or pull requests

7 participants