Skip to content

Commit

Permalink
Merge pull request dependabot#6798 from dependabot/mctofu/python-reso…
Browse files Browse the repository at this point in the history
…urce-errors

Detect when pip compile hits memory or disk limits
  • Loading branch information
mctofu authored Mar 7, 2023
2 parents a72d598 + ebd13a9 commit a34040e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ def handle_pip_compile_errors(error)
raise GitDependenciesNotReachable, url
end

raise Dependabot::OutOfDisk if error.message.end_with?("[Errno 28] No space left on device")

raise Dependabot::OutOfMemory if error.message.end_with?("MemoryError")

raise
end
# rubocop:enable Metrics/AbcSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,5 +387,43 @@
end
end
end

context "that fails to resolve due to resource limits" do
context "because it ran out of disk space" do
before do
allow(Dependabot::SharedHelpers).
to receive(:run_shell_command).
and_raise(
Dependabot::SharedHelpers::HelperSubprocessFailed.new(
message: "OSError: [Errno 28] No space left on device",
error_context: {}
)
)
end

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

context "because it ran out of memory" do
before do
allow(Dependabot::SharedHelpers).
to receive(:run_shell_command).
and_raise(
Dependabot::SharedHelpers::HelperSubprocessFailed.new(
message: "MemoryError",
error_context: {}
)
)
end

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

0 comments on commit a34040e

Please sign in to comment.