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

Only use credentials which have registry configured #9159

Merged
merged 4 commits into from
Mar 2, 2024

Conversation

JamieMagee
Copy link
Contributor

We're seeing exceptions like this:

ERROR <job_f1193657-1f45-4e15-a1c9-f51909c517e2> Error processing @babel/traverse (NoMethodError)
ERROR <job_f1193657-1f45-4e15-a1c9-f51909c517e2> undefined method `gsub' for nil:NilClass
 
               url = "#{details['registry'].gsub(%r{/+$}, '')}/#{escaped_dependency_name}"
                                           ^^^^^
ERROR <job_f1193657-1f45-4e15-a1c9-f51909c517e2> /home/dependabot/npm_and_yarn/lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb:78:in `block in first_registry_with_dependency_details'

This should prevent us selecting credentials which are missing the registry key.

@JamieMagee JamieMagee requested a review from a team as a code owner February 28, 2024 21:23
@abdulapopoola
Copy link
Member

please can we get a test for this?

@JamieMagee
Copy link
Contributor Author

Will add a test.

CI failures are due to rate limits.

@JamieMagee
Copy link
Contributor Author

The unit test fails on main with the following error

dependabot-core/npm_and_yarn on  main [$!]
❯ bundle exec rspec spec/dependabot/npm_and_yarn/update_checker/registry_finder_spec.rb

Randomized with seed 56745
.................F............................

Failures:

  1) Dependabot::NpmAndYarn::UpdateChecker::RegistryFinder registry with credentials that don't have a registry
     Failure/Error: url = "#{details['registry'].gsub(%r{/+$}, '')}/#{escaped_dependency_name}"

     NoMethodError:
       undefined method `gsub' for nil:NilClass

                     url = "#{details['registry'].gsub(%r{/+$}, '')}/#{escaped_dependency_name}"
                                                 ^^^^^
     # ./lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb:78:in `block in first_registry_with_dependency_details'
     # ./lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb:77:in `each'
     # ./lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb:77:in `find'
     # ./lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb:77:in `first_registry_with_dependency_details'
     # ./lib/dependabot/npm_and_yarn/update_checker/registry_finder.rb:34:in `registry'
     # ./spec/dependabot/npm_and_yarn/update_checker/registry_finder_spec.rb:160:in `block (3 levels) in <top (required)>'
     # ./spec/dependabot/npm_and_yarn/update_checker/registry_finder_spec.rb:414:in `block (4 levels) in <top (required)>'
     # /home/jamie/src/work/dependabot-core/common/spec/spec_helper.rb:47:in `block (2 levels) in <top (required)>'

Finished in 0.04251 seconds (files took 0.77595 seconds to load)
46 examples, 1 failure

Failed examples:

rspec ./spec/dependabot/npm_and_yarn/update_checker/registry_finder_spec.rb:414 # Dependabot::NpmAndYarn::UpdateChecker::RegistryFinder registry wi
th credentials that don't have a registry

Same as we see in production.

@abdulapopoola abdulapopoola merged commit 945b9c1 into main Mar 2, 2024
65 checks passed
@abdulapopoola abdulapopoola deleted the jamiemagee/npm-credential-handling branch March 2, 2024 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants