From a7f6a676f146278ca2846a83578d3652ac0c49f1 Mon Sep 17 00:00:00 2001 From: Rob Aiken Date: Tue, 17 Dec 2024 19:00:28 +0000 Subject: [PATCH] improving error message --- common/lib/dependabot/errors.rb | 17 +++++++++++++++++ .../dependabot/github_actions/file_parser.rb | 2 +- .../github_actions/file_parser_spec.rb | 8 +++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/common/lib/dependabot/errors.rb b/common/lib/dependabot/errors.rb index b2e9b3dae0..a702f8b628 100644 --- a/common/lib/dependabot/errors.rb +++ b/common/lib/dependabot/errors.rb @@ -661,6 +661,23 @@ def initialize(dependencies) end end + class UnresolvableVersionError < DependabotError + extend T::Sig + + sig { returns(T::Array[String]) } + attr_reader :dependencies + + sig { params(dependencies: T::Array[String]).void } + def initialize(dependencies) + @dependencies = dependencies + + msg = "Unable to determine semantic version from tags or commits for dependencies. " \ + "Dependencies must have a tag or commit that references a semantic version. " \ + "Affected dependencies: #{@dependencies.join(', ')}" + super(msg) + end + end + class GitDependenciesNotReachable < DependabotError extend T::Sig diff --git a/github_actions/lib/dependabot/github_actions/file_parser.rb b/github_actions/lib/dependabot/github_actions/file_parser.rb index ecadd0a6f7..87c48fb3c9 100644 --- a/github_actions/lib/dependabot/github_actions/file_parser.rb +++ b/github_actions/lib/dependabot/github_actions/file_parser.rb @@ -36,7 +36,7 @@ def parse end dependencies_without_version = dependency_set.dependencies.select { |dep| dep.version.nil? } - raise UpdateNotPossible, dependencies_without_version.map(&:name) unless dependencies_without_version.empty? + raise UnresolvableVersionError, dependencies_without_version.map(&:name) unless dependencies_without_version.empty? dependency_set.dependencies end diff --git a/github_actions/spec/dependabot/github_actions/file_parser_spec.rb b/github_actions/spec/dependabot/github_actions/file_parser_spec.rb index 13f6c1a7e7..6ee4d2e6bd 100644 --- a/github_actions/spec/dependabot/github_actions/file_parser_spec.rb +++ b/github_actions/spec/dependabot/github_actions/file_parser_spec.rb @@ -572,10 +572,12 @@ def mock_service_pack_request(nwo) mock_service_pack_request("taiki-e/install-action") end - it "raises an UpdateNotPossible error" do + it "raises an UnresolvableVersionError error" do expect { parser.parse }.to raise_error( - Dependabot::UpdateNotPossible, - "The following dependencies could not be updated: taiki-e/install-action" + Dependabot::UnresolvableVersionError, + "Unable to determine semantic version from tags or commits for dependencies. " \ + "Dependencies must have a tag or commit that references a semantic version. " \ + "Affected dependencies: taiki-e/install-action" ) end end