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

Fix yanked library problems in Poetry not detected when lockfile is present #7832

Merged
merged 2 commits into from
Aug 18, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def handle_poetry_errors(error)
end

raise unless error.message.include?("SolverProblemError") ||
error.message.include?("PackageNotFound") ||
error.message.include?("not found") ||
error.message.include?("version solving failed.")

check_original_requirements_resolvable
Expand Down Expand Up @@ -168,7 +168,7 @@ def check_original_requirements_resolvable
@original_reqs_resolvable = true
rescue SharedHelpers::HelperSubprocessFailed => e
raise unless e.message.include?("SolverProblemError") ||
e.message.include?("PackageNotFound") ||
e.message.include?("not found") ||
e.message.include?("version solving failed.")

msg = clean_error_message(e.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
let(:pyproject_fixture_name) { "poetry_exact_requirement.toml" }
let(:lockfile) do
Dependabot::DependencyFile.new(
name: "pyproject.lock",
name: "poetry.lock",
content: fixture("pyproject_locks", lockfile_fixture_name)
)
end
Expand Down Expand Up @@ -168,7 +168,7 @@
end
end

context "with a dependency file that includes a git dependency", :slow do
context "with a dependency file that includes a git dependency" do
let(:pyproject_fixture_name) { "git_dependency.toml" }
let(:lockfile_fixture_name) { "git_dependency.lock" }
let(:dependency_name) { "pytest" }
Expand All @@ -185,28 +185,30 @@

it { is_expected.to eq(Gem::Version.new("3.8.2")) }

context "that has a bad reference" do
let(:pyproject_fixture_name) { "git_dependency_bad_ref.toml" }
let(:lockfile_fixture_name) { "git_dependency_bad_ref.lock" }
context "that has no lockfile" do
let(:dependency_files) { [pyproject] }

it "raises a helpful error" do
expect { subject }.
to raise_error(Dependabot::GitDependencyReferenceNotFound) do |err|
expect(err.dependency).to eq("toml")
end
context "that has a bad reference, and no lockfile" do
let(:pyproject_fixture_name) { "git_dependency_bad_ref.toml" }

it "raises a helpful error" do
expect { subject }.
to raise_error(Dependabot::GitDependencyReferenceNotFound) do |err|
expect(err.dependency).to eq("toml")
end
end
end
end

context "that is unreachable" do
let(:pyproject_fixture_name) { "git_dependency_unreachable.toml" }
let(:lockfile_fixture_name) { "git_dependency_unreachable.lock" }
context "that is unreachable" do
let(:pyproject_fixture_name) { "git_dependency_unreachable.toml" }

it "raises a helpful error" do
expect { subject }.
to raise_error(Dependabot::GitDependenciesNotReachable) do |error|
expect(error.dependency_urls).
to eq(["https://github.com/greysteil/unreachable.git"])
end
it "raises a helpful error" do
expect { subject }.
to raise_error(Dependabot::GitDependenciesNotReachable) do |error|
expect(error.dependency_urls).
to eq(["https://github.com/greysteil/unreachable.git"])
end
end
end
end
end
Expand Down Expand Up @@ -260,16 +262,31 @@
end

context "because of a yanked dependency" do
let(:dependency_files) { [pyproject, lockfile] }
let(:pyproject_fixture_name) { "yanked_version.toml" }
let(:lockfile_fixture_name) { "yanked_version.lock" }

it "raises a helpful error" do
expect { subject }.
to raise_error(Dependabot::DependencyFileNotResolvable) do |error|
expect(error.message).
to include("depends on croniter (0.3.26) which doesn't match any versions")
end
context "with a lockfile" do
let(:dependency_files) { [pyproject, lockfile] }

it "raises a helpful error" do
expect { subject }.
to raise_error(Dependabot::DependencyFileNotResolvable) do |error|
expect(error.message).
to include("Package croniter (0.3.26) not found")
end
end
end

context "without a lockfile" do
let(:dependency_files) { [pyproject] }

it "raises a helpful error" do
expect { subject }.
to raise_error(Dependabot::DependencyFileNotResolvable) do |error|
expect(error.message).
to include("depends on croniter (0.3.26) which doesn't match any versions")
end
end
end
end
end
Expand Down
119 changes: 0 additions & 119 deletions python/spec/fixtures/pyproject_locks/git_dependency_bad_ref.lock

This file was deleted.

119 changes: 0 additions & 119 deletions python/spec/fixtures/pyproject_locks/git_dependency_unreachable.lock

This file was deleted.