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

Fixes exception handler for file_not_parseable under file_updater and fixes error handler for package not found error #10619

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions common/lib/dependabot/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def self.parser_error_details(error)

# rubocop:disable Lint/RedundantCopDisableDirective
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/AbcSize
sig { params(error: StandardError).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
def self.updater_error_details(error)
case error
Expand Down Expand Up @@ -226,6 +227,14 @@ def self.updater_error_details(error)
"error-message": error.message
}
}
when Dependabot::DependencyFileNotParseable
{
"error-type": "dependency_file_not_parseable",
"error-detail": {
message: error.message,
"file-path": error.file_path
}
}
when Dependabot::OutOfDisk
{
"error-type": "out_of_disk",
Expand Down Expand Up @@ -281,6 +290,7 @@ def self.updater_error_details(error)
end
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Metrics/AbcSize
# rubocop:enable Lint/RedundantCopDisableDirective

class DependabotError < StandardError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def dependency_name
end

package_name = url_base.gsub("%2F", "/").match(%r{@.*/})
"#{T.must(package_name)}#{T.must(url_base.gsub('%2F', '/').split('/').last)}"

return T.must(url_base.gsub("%2F", "/").split("/").last) unless package_name

"#{package_name}#{T.must(url_base.gsub('%2F', '/').split('/').last)}"
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@
end
end

context "when there is a private registry and package name is not specified" do
let(:project_name) { "pnpm/private_package_access_no_package_name" }

it "raises a helpful error" do
expect { updated_pnpm_lock_content }
.to raise_error(Dependabot::DependencyNotFound)
end
end

context "when there is a unsupported engine response (pnpm) from registry" do
let(:dependency_name) { "eslint" }
let(:version) { "9.9.0" }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://npm.pkg.github.com
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"dep-2": "1.0.3"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading