urbanadventurer/WhatWeb · error
You must specify the available versions of the product
Error message
You must specify the available versions of the product
What it means
Version#initialize in WhatWeb's version_class.rb requires a product name, an available-versions value, and a URL. When the `versions` argument is nil (or omitted), the constructor raises this error before any instance state is set. It is a guard against creating a Version object that has no version data to compare or download against.
Solutions
- Pass a non-nil versions value as the second argument to Version.new, e.g. an array or string of versions
- Check the variable feeding the versions argument for nil before constructing the Version
- Verify argument order: initialize(name_product, versions, url) — ensure url was not shifted into the versions slot
- Default to an empty-but-non-nil structure like [] if the caller intentionally has no known versions
Example fix
// before
v = Version.new('Apache', nil, 'http://example.com')
// after
v = Version.new('Apache', ['2.4.57', '2.4.58'], 'http://example.com') Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError, 'versions is required' if versions.nil?
v = Version.new('Apache', versions, 'http://example.com') Type guard
def valid_versions?(v) !v.nil? end
Prevention
- Check all three constructor arguments for nil before calling Version.new
- Remember argument order: name, versions, url
- Treat empty lookup results as [] rather than nil
- Unit-test plugin constructors with nil arguments
When it happens
Trigger: Calling Version.new(name, nil, url) or Version.new(name, url: ...) with the second positional argument omitted, or passing a variable that evaluated to nil (e.g. an empty lookup result used as the versions argument).
Common situations: Plugins or helper scripts construct a Version to fetch version-specific files after a match, but the versions list was never populated because an earlier scrape/regex found nothing; positional-argument mix-ups where url is passed as the second argument leaving versions nil.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- You must specify the available url of the website
- No target
- Error parsing target IP range: #
- Unable to parse invalid target. No hostname.
- You must specify the name of the product
AI-assisted analysis of urbanadventurer/WhatWeb@d279d93042 (2026-09-15).
Data as JSON: /api/errors/3508a19c06b7b10b.
Report an issue: GitHub.
Appendix: source
Thrown at lib/version_class.rb:21
# This file is part of WhatWeb.
#
# WhatWeb is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# at your option) any later version.
#
# WhatWeb is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with WhatWeb. If not, see <http://www.gnu.org/licenses/>.
class Version
def initialize(name_product = nil, versions = nil, url = nil)
raise 'You must specify the name of the product' if name_product.nil?
raise 'You must specify the available versions of the product' if versions.nil?
raise 'You must specify the available url of the website' if url.nil?
@name = name_product
@versions = versions
@files = Hash['filenames' => [], 'files' => [], 'md5' => []]
@url = url
@got_best_versions = false
@best_versions = []
versions.each do |version|
version[1].each do |file|
next if @files['filenames'].include? file[0]
@files['filenames'].push(file[0])
@files['files'].push(URI.join(@url.to_s, file[0]).to_s)
_status, url, _ip, body, _headers = open_target(@files['files'].last)
@files['md5'].push(Digest::MD5.hexdigest(body))
end
endView on GitHub (pinned to d279d93042)