Commit 62052283 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '119333-systemstackerror-stack-level-too-deep' into 'master'

Prevent stack overflowing with a lot of user references

Closes #119333

See merge request gitlab-org/gitlab!22247
parents c3fa73f9 e8faadae
......@@ -177,7 +177,7 @@ module Banzai
collection.where(id: to_query).each { |row| cache[row.id] = row }
end
cache.values_at(*ids).compact
ids.uniq.map { |id| cache[id] }.compact
else
collection.where(id: ids)
end
......
......@@ -312,6 +312,12 @@ describe Banzai::ReferenceParser::BaseParser do
expect(subject.collection_objects_for_ids(Project, [project.id]))
.to eq([project])
end
it 'will not overflow the stack' do
ids = 1.upto(1_000_000).to_a
expect { subject.collection_objects_for_ids(User, ids) }.not_to raise_error
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment