Skip to content

Commit a607fde

Browse files
committed
Add nil guard to ProcessModel.run_action_user
* prevents exceptions "docker? delegated to app, but app is nil" when listing large number of processes on a live system
1 parent c385a36 commit a607fde

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

app/models/runtime/process_model.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ def started_command
384384

385385
def run_action_user
386386
return user if user.present?
387+
return nil if app.nil?
387388

388389
docker? ? docker_run_action_user : AppModel::DEFAULT_CONTAINER_USER
389390
end

spec/unit/models/runtime/process_model_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,17 @@ def act_as_cf_admin
747747
end
748748
end
749749
end
750+
751+
context 'when the associated app is nil' do
752+
before do
753+
process.app = nil
754+
end
755+
756+
it 'does not raise an error and returns nil' do
757+
expect{process.run_action_user}.not_to raise_error
758+
expect(process.run_action_user).to be_nil
759+
end
760+
end
750761
end
751762

752763
describe '#specified_or_detected_command' do

0 commit comments

Comments
 (0)