Skip to content

importmap audit panics when npm returns an HTTP failure code #300

Open
@tmeire

Description

@tmeire

During a widespread outage today, I tried to run an importmap audit, but the command panicked with a rather unclear message because it was unable to download the list of vulnerabilities from the NPM registry.

    ▶ bin/importmap audit
    /opt/homebrew/lib/ruby/gems/3.4.0/gems/importmap-rails-2.1.0/lib/importmap/npm.rb:38:in 'block in Importmap::Npm#vulnerable_packages': undefined method 'map' for an instance of String (NoMethodError)
    
          vulnerabilities.map do |vulnerability|
                         ^^^^
    Did you mean?  tap
    	from /opt/homebrew/lib/ruby/gems/3.4.0/gems/importmap-rails-2.1.0/lib/importmap/npm.rb:37:in 'Hash#each'
    	from /opt/homebrew/lib/ruby/gems/3.4.0/gems/importmap-rails-2.1.0/lib/importmap/npm.rb:37:in 'Enumerable#flat_map'
    	from /opt/homebrew/lib/ruby/gems/3.4.0/gems/importmap-rails-2.1.0/lib/importmap/npm.rb:37:in 'Importmap::Npm#vulnerable_packages'
    	from /opt/homebrew/lib/ruby/gems/3.4.0/gems/importmap-rails-2.1.0/lib/importmap/commands.rb:75:in 'Importmap::Commands#audit'
    	from /opt/homebrew/lib/ruby/gems/3.4.0/gems/thor-1.3.2/lib/thor/command.rb:28:in 'Thor::Command#run'
    	from /opt/homebrew/lib/ruby/gems/3.4.0/gems/thor-1.3.2/lib/thor/invocation.rb:127:in 'Thor::Invocation#invoke_command'
    	from /opt/homebrew/lib/ruby/gems/3.4.0/gems/thor-1.3.2/lib/thor.rb:538:in 'Thor.dispatch'
    	from /opt/homebrew/lib/ruby/gems/3.4.0/gems/thor-1.3.2/lib/thor/base.rb:584:in 'Thor::Base::ClassMethods#start'
    	from /opt/homebrew/lib/ruby/gems/3.4.0/gems/importmap-rails-2.1.0/lib/importmap/commands.rb:159:in '<main>'
    	from /opt/homebrew/Cellar/ruby/3.4.2/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require'
    	from /opt/homebrew/Cellar/ruby/3.4.2/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
    	from /opt/homebrew/lib/ruby/gems/3.4.0/gems/bootsnap-1.18.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in 'Kernel#require'
    	from /opt/homebrew/lib/ruby/gems/3.4.0/gems/zeitwerk-2.7.3/lib/zeitwerk/core_ext/kernel.rb:34:in 'Kernel#require'
    	from bin/importmap:4:in '<main>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions