CommitService.GetTreeEntries must not set an empty pagination cursor
For sub messages, there is a difference between no value and default value (this is not the case for primitive types).
The lack of value becomes nil
in the Ruby client library.
For context, GetTreeEntries
is both "chunked" (returns a stream of messages) and paginated (one call per page, under control of the caller).
Each chunk yielded by GetTreeEntries()
has the pagination_cursor
attribute, with pagination_cursor.next_cursor
being the empty string for all of them except the first. The correct behavior would be to set the pagination_cursor
attribute only on the first chunk.
On the Rails side, the result is that this empty string is not discarded and overrides any cursor set in the first chunk, and the subsequent pages are never retrieved. From lib/gitlab/gitaly_client/commit_service.rb
:
cursor = nil
entries = response.flat_map do |message|
cursor = message.pagination_cursor if message.pagination_cursor # condition always true, overrides cursor with empty string in 2nd message and following
message.entries.map do |gitaly_tree_entry|
Gitlab::Git::Tree.new(...)
end
end
[entries, cursor]
end # returning thus overridden cursor value.
Correction task list:
-
fix the issue -
find a way for Gitaly Comparison tests to detect such differences