Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 3765e10

Browse files
committed
Handle Open3 returning a nil status
Customers are experiencing this in production. It results in an engine error output of: NoMethodError: undefined method `success?' for nil:NilClass block in run at /usr/src/app/lib/cc/engine/analyzers/command_line_runner.rb:18 The included spec reproduces this error. It's unclear what circumstances lead to this, but removing the NoMethodError will at least let the engine's stderr come through, which we can then debug and address thereafter.
1 parent 8028216 commit 3765e10

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/cc/engine/analyzers/command_line_runner.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ def initialize(command, timeout = DEFAULT_TIMEOUT)
1515
def run(input)
1616
Timeout.timeout(timeout) do
1717
out, err, status = Open3.capture3(command, stdin_data: input)
18-
if status.success?
18+
if status && status.success?
1919
yield out
2020
else
21-
raise ::CC::Engine::Analyzers::ParserError, "`#{command}` exited with code #{status.exitstatus}:\n#{err}"
21+
exitstatus = status && status.exitstatus
22+
raise ::CC::Engine::Analyzers::ParserError, "`#{command}` exited with code #{exitstatus}:\n#{err}"
2223
end
2324
end
2425
end

spec/cc/engine/analyzers/command_line_runner_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ module CC::Engine::Analyzers
2626

2727
expect { runner.run("") }.to raise_error(Timeout::Error)
2828
end
29+
30+
it "handles Open3 returning a nil status" do
31+
runner = CommandLineRunner.new("")
32+
33+
allow(Open3).to receive(:capture3).and_return(["", "error output", nil])
34+
35+
expect { runner.run("") }.to raise_error(
36+
ParserError, /code :\nerror output/
37+
)
38+
end
2939
end
3040
end
3141
end

0 commit comments

Comments
 (0)