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: SAM build does not abort when missing npm library #7530

Closed
pguartes-endava opened this issue Oct 2, 2024 · 2 comments
Closed

Bug: SAM build does not abort when missing npm library #7530

pguartes-endava opened this issue Oct 2, 2024 · 2 comments
Labels
stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Comments

@pguartes-endava
Copy link

Description:

Sometimes SAM has an issue getting versions of libraries it needs for the build process, this problem manifests as the following error:

15:59:54 Error: NodejsNpmBuilder:NpmInstall - NPM Failed: npm WARN config production Use --omit=dev instead. 15:59:54 npm ERR! code ETARGET 15:59:54 npm ERR! notarget No matching version found for @babel/helper-validator-identifier@^7.25.7. 15:59:54 npm ERR! notarget In most cases you or one of your dependencies are requesting 15:59:54 npm ERR! notarget a package version that doesn't exist.

But the build does not stop after that, it generates a faulty package and we do not get an error code, so our CI/CD pipeline continues with the sam deploy command and deploys the faulty package that does not work at all.

Steps to reproduce:

It happens when a library that SAM uses gets a new version, I'm not sure if this behavior can be simulated some other way.

Observed result:

On 09/16 this error happened with the following library:

https://www.npmjs.com/package/@smithy/node-config-provider

16:52:54 npm ERR! notarget No matching version found for @smithy/node-config-provider@^3.1.6.

Today on 02/10 it happened with this library

https://www.npmjs.com/package/@babel/helper-validator-identifier

15:58:02 Building layer 'SDPLayers/BackendLayer' 15:58:02 WARNING: Layer 'BackendLayer' has BuildArchitecture x86_64, which is not listed in CompatibleArchitectures 15:58:02 Running NodejsNpmBuilder:NpmPack 15:58:03 Running NodejsNpmBuilder:CopyNpmrcAndLockfile 15:58:03 Running NodejsNpmBuilder:CopySource 15:58:03 Running NodejsNpmBuilder:NpmInstall 15:59:54 15:59:54 Build Failed 15:59:54 Error: NodejsNpmBuilder:NpmInstall - NPM Failed: npm WARN config production Use --omit=dev instead. 15:59:54 npm ERR! code ETARGET 15:59:54 npm ERR! notarget No matching version found for @babel/helper-validator-identifier@^7.25.7. 15:59:54 npm ERR! notarget In most cases you or one of your dependencies are requesting 15:59:54 npm ERR! notarget a package version that doesn't exist. 15:59:54 15:59:54 npm ERR! A complete log of this run can be found in: 15:59:54 npm ERR! /home/node/.npm/_logs/2024-10-02T18_58_02_731Z-debug-0.log 15:59:58 15:59:58 Uploading to sdp-dev-stack/bc137888fe1f28514c7a745dd59ee3b5 262144 / 1736109 (15.10%) 15:59:58 Uploading to sdp-dev-stack/bc137888fe1f28514c7a745dd59ee3b5 524288 / 1736109 (30.20%) 15:59:58 Uploading to sdp-dev-stack/bc137888fe1f28514c7a745dd59ee3b5 786432 / 1736109 (45.30%) 15:59:58 Uploading to sdp-dev-stack/bc137888fe1f28514c7a745dd59ee3b5 1048576 / 1736109 (60.40%) 15:59:58 Uploading to sdp-dev-stack/bc137888fe1f28514c7a745dd59ee3b5 1310720 / 1736109 (75.50%) 15:59:59 Uploading to sdp-dev-stack/bc137888fe1f28514c7a745dd59ee3b5 1572864 / 1736109 (90.60%) 15:59:59 Uploading to sdp-dev-stack/bc137888fe1f28514c7a745dd59ee3b5 1736109 / 1736109 (100.00%) 15:59:59 15:59:59 Uploading to sdp-dev-stack/8fa6a45e0956f135560f0174b206b041.template 912 / 912 (100.00%)

Expected result:

SAM should throw an error code so that the CI/CD scripts can know there was an error on the build and abort the deployment. We get the "Build failed" message but it seems that the code returned is zero, otherwise our pipelines would abort

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Linux
  2. sam --version: 1.120.0
  3. AWS region: us-east-1
@pguartes-endava pguartes-endava added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Oct 2, 2024
@pguartes-endava pguartes-endava changed the title Bug: SAM build does not abort when missing node library Bug: SAM build does not abort when missing npm library Oct 2, 2024
Copy link
Contributor

github-actions bot commented Oct 3, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@pguartes-endava
Copy link
Author

It seems the code returned is not 0 so it was an error on our pipeline, sorry for the inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.
Projects
None yet
Development

No branches or pull requests

1 participant