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

npm install fails on first attempt with 403 error when accessing Azure Artifacts, succeeds on second attempt #7246

Open
2 tasks done
igbaryyaAMD opened this issue Feb 25, 2024 · 2 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@igbaryyaAMD
Copy link

igbaryyaAMD commented Feb 25, 2024

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

Current Behavior

When running npm install in my project that is configured to use a private Azure Artifacts feed, the first attempt fails with a 403 error, indicating a server authentication failure. The error message suggests an issue with the formation of the Authorization header's value.

Error Details

  • Command: npm install
  • Error Message:
5231 timing command:i Completed in 96964ms
5232 verbose stack HttpErrorGeneral: 403 Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
...
5239 error code E403
5240 error 403 Server failed to authenticate the request.
5241 error 403 In most cases, you or one of your dependencies are requesting a package version that is forbidden by your security policy.
5242 verbose exit 1
  • Node.js Version: 20.11.1
  • npm Version: 10.2.4
  • Operating System: Darwin 22.4.0
  • Project Path: /local/path/to/my/prj

Reproduction Steps

  1. Navigate to the project directory.
  2. Run npm install.
  3. Observe the 403 error on the first attempt.

Additional Context

  • This issue occurs across various environments:
  1. Dockerfile Build: Encountered the same issue when building within Docker.
  2. Unix Environment: The issue persists in Unix environments.
  3. MacOS: Similar behavior is observed on my MacOS system.
  • The problem seems to be specific to the latest version of npm. When using an older version of npm, the installation process completes without any errors on the first attempt.
  • Interestingly, if I immediately re-run npm install without making any changes (including not clearing the npm cache), the installation succeeds on the second attempt. This behavior is consistent, and my .npmrc credentials have been verified to be correct.

Expected Behavior

Expected Behavior

When executing npm install in a project configured to use a private Azure Artifacts feed, the installation should succeed on the first attempt without encountering authentication errors, assuming that the .npmrc configuration and credentials are correctly set up.

Key Points

  • Successful Installation: The npm install command should successfully install all dependencies without errors on the first attempt.
  • Authentication: The process should seamlessly authenticate against Azure Artifacts using the credentials provided in the .npmrc file, without requiring multiple attempts or manual intervention.
  • Error Handling: In case of genuine authentication issues, a clear and actionable error message should be provided, guiding the user towards resolving the configuration or credential issues.

Ideal Outcome

  • The installation process is smooth and predictable, enhancing developer productivity and minimizing disruptions caused by intermittent failures.
  • Developers can rely on the consistency of the npm install command, especially in automated environments like continuous integration pipelines, where manual retries are not feasible.

Steps To Reproduce

  1. Navigate to the project directory.
  2. Run npm install.
  3. Observe the 403 error on the first attempt.

Environment

Environment

The issue has been reproduced across multiple environments, each time with the same unexpected behavior on the initial npm install command. Here are the details of the environments where the issue was observed:

  • npm Version:
    • Local development environment: npm 10.2.4
    • Docker build environment: [include npm version used in Docker]
    • Unix environment: [include npm version used on Unix]
  • Node.js Version:
    • Local development environment: Node.js 20.11.1
    • Docker build environment: [include Node.js version used in Docker]
    • Unix environment: [include Node.js version used on Unix]
  • Operating Systems:
    • Local development environment: MacOS Darwin 22.4.0
    • Docker build environment: [include OS used in Docker, e.g., Alpine Linux 3.13]
    • Unix environment: [include specific Unix OS name and version, e.g., Ubuntu 20.04]
  • System Model Name:
    • Local development environment: [include System Model, e.g., MacBook Pro]

Additional configuration details:

  • Dockerfile build is configured with the same .npmrc and environment variables as the local environment.
  • The Unix environment is a clean install of the operating system with the same npm and Node.js versions as the local environment.
  • This issue is not observed when using previous versions of npm (e.g., npm 8.x.x) across the same environments.
@igbaryyaAMD igbaryyaAMD added Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x labels Feb 25, 2024
@gitnubster
Copy link

@igbaryyaAMD It looks solved for me with npm 10.5.0 / node 20.12.0 and 18.20.0

@tatejones
Copy link

tatejones commented Mar 28, 2024

I am experiencing the same issue with npm ci and I on the Azure Artefacts. npm 10.2.4 node 18.19.1. Very intermittent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps
Projects
None yet
Development

No branches or pull requests

4 participants