Skip to content

Unable to push or pull because packaging API overrides fails #14232

@danrivett

Description

@danrivett

How did you install the Amplify CLI?

npm -g i @aws-amplify/cli

If applicable, what version of Node.js are you using?

v20.18.1

Amplify CLI Version

13.0.1

What operating system are you using?

MacOS

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

Added override.ts file.

It's likely outside the scope of this ticket, but this was used to customize datasource for some GraphQL DynamoDB mutations to use transactWriteItem to ensure non-duplicate email addresses on user records (as the email address isn't the main record's primary key so we used transactWriteItem to also write to a "unique ids" separate table where the email address written there is that table's PK).

Describe the bug

I just upgraded amplify-cli from 12.14.1 to 13.0.1 and since that upgrade I'm getting the following error:

🛑 Packaging overrides failed.
Command failed with exit code 1: yarn tsc --project xxx/amplify/backend/api/yyy/build/tsconfig.resource.json
error Command "tsc" not found.
yarn run v1.22.19
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I've tracked it down to changes made in #14093. In particular this change to override-skeleton-generator.ts.

This could be an issue on our side but the change that PR introduces to that file will work for us if we change the cwd argument on the line below:

-      cwd: tsConfigDir,
+      cwd: cwd,

I'm unclear how it's working for everyone else with cwd set to tsConfigDir since the overrides' package.json is installed just above this using cwd as the current working directory:

execa.sync(packageManager.executable, ['install'], {
      cwd,
      stdio: 'pipe',
      encoding: 'utf-8',
    });

So the node_modules is under cwd and not tsConfigDir. Using tsConfigDir results in yarn not being able to find tsc after this PR.

I don't understand this code enough to definitely know it's an issue on our end, which is why I created this ticket, even though it may be down to some customization or old version of our application since it was created several years ago, so any insight would be really appreciated.

I'm surprised this is working for everyone else but we do have a few customizations in our code base (hence the override.ts file).

Adding to my confusion is that the tsconfig.ts that's in cwd not tsConfigDir contains:

"outDir": "build"

So that also makes me expect tsc to be run from cwd and output to the tsConfigDir (which is set to a build sub-directory). But again I'm fairly confused, so I could be completely misunderstanding this.

Expected behavior

amplify push should build API overrides resource successfully before deploying.

Reproduction steps

  1. Create an API override.ts file by running amplify override api
  2. Run amplify push

Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

Metadata

Metadata

Assignees

No one assigned

    Labels

    not-reproducibleNot able to reproduce the issuepending-responseIssue is pending response from the issue authorquestionGeneral question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions