aws-pdk icon indicating copy to clipboard operation
aws-pdk copied to clipboard

[BUG] type-safe-api build fails when AWS_PDK_VERSION is not set in the environment

Open memorsolutions opened this issue 1 year ago • 1 comments

Describe the bug

running pnpm build from the monorep root fails inside type-safe-api with multiple errors ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Cannot read properties of undefined

I first ran into the issue while attempting to develop a new feature within the baseline type-safe-api. Upon changing a source file (even as simple as adding an empty // comment to the end of a line, running pnpm build at the top level fails. This indeed happens any time there is a cache miss for the tpe-safe-api nx cloud cache. This can be observed in a fresh git (no changes) and running pnpm build --skip-nx-cache.

After some exploration, it seems that when working on a local machine, unless AWS_PDK_VERSION is explicitly set in the environment, the build will fail.

Expected Behavior

I expect a build to work out of the box.

Current Behavior

Without AWS_PDK_VERSION set, pnpm build eventually encounters multiple failures within type-safe-api in the general form of:

@aws/type-safe-api: running command pnpm exec ts-node pre-process-spec.ts --specPath=/tmp/tmp.X4i3yn/infra/../spec.yaml --outputSpecPath=/tmp/generate-client-python-async-cdk-infrastructure.9AanYF04M/.preprocessed-api.json --extraVendorExtensions={"x-runtime-module-name":"test_client","x-relative-spec-path":"../../spec.yaml","x-handlers-python-module":"","x-handlers-java-package":"","x-handlers-typescript-asset-path":"","x-handlers-python-asset-path":"","x-handlers-java-asset-path":"","x-handlers-node-lambda-runtime-version":"","x-handlers-python-lambda-runtime-version":"","x-handlers-java-lambda-runtime-version":""}
@aws/type-safe-api: undefined
@aws/type-safe-api:  ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Cannot read properties of undefined (reading '/tmp/generate-client-python-async-cdk-infrastructure.9AanYF04M')

Reproduction Steps

Build fails:

git clone git clone https://github.com/aws/aws-pdk.git
cd aws-pdk
pnpm i
pnpm build --skip-nx-cache

Build succeeds:

git clone git clone https://github.com/aws/aws-pdk.git
cd aws-pdk
pnpm i
AWS_PDK_VERSION=0.23.47 pnpm build --skip-nx-cache

Possible Solution

It's unclear if this is an issue with packages/type-safe-api/scripts/type-safe-api/common/common.sh, or if it is the documentation in docs/content/contributing/index.md that lacks clear instructions on the correct way to build when contributing to the type-safe-api package.

Additional Information/Context

No response

PDK version used

0.23.46, 0.23.47

What languages are you seeing this issue on?

No response

Environment details (OS name and version, etc.)

Ubuntu 22.04

memorsolutions avatar Jul 26 '24 21:07 memorsolutions

Hi John,

Sorry for the slow reply - just back from leave!

Interesting, I'm not able to reproduce this!

I cleaned my ~/.pdk directory before cloning and building the repo - AWS_PDK_VERSION being unset means it creates a directory named ~/.pdk/type-safe-api rather than the usual ~/.pdk/$AWS_PDK_VERSION/type-safe-api etc, but the build still succeeds. My first guess was could it be the double / when it tries to mkdir ~/.pdk//type-safe-api, but it seems like it's pretty standard for posix to treat multiple slashes as a single one.

I wonder if you've had a chance to look into this any further?

Cheers, Jack

cogwirrel avatar Sep 17 '24 07:09 cogwirrel

Hey, Jack.

Just getting back to revisiting. I believe I've narrowed it down to something in my dev environment, different version of something. Still not sure what, but I was able to get the build to work using the devcontainer. So I'll go ahead and close this one. I just created a new issue #839 dealing with the devcontainer and plan to submit a pull request on that.

memorsolutions avatar Oct 07 '24 11:10 memorsolutions

Awesome, thanks so much!

cogwirrel avatar Oct 07 '24 22:10 cogwirrel