Bug: Zoekt num_context_lines is hardcoded instead of respecting API parameter
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Description
The Zoekt search client hardcodes num_context_lines to 1, ignoring the num_context_lines parameter passed via the API. This is inconsistent with Elasticsearch and violates the documented API behavior.
Current behavior
In ee/lib/gitlab/search/zoekt/client.rb (line 8), the context lines count is hardcoded:
CONTEXT_LINES_COUNT = 1This constant is then always passed to the Zoekt search request (line 35):
num_context_lines: CONTEXT_LINES_COUNT,The API parameter num_context_lines is accepted but completely ignored.
Expected behavior
According to the API documentation, num_context_lines should be configurable and respected by both Elasticsearch and Zoekt search backends. Users should be able to specify 0 to MAX_NUM_CONTEXT_LINES (20) context lines.
Impact
- Users cannot control the number of context lines returned by Zoekt searches
- Inconsistent behavior between Elasticsearch and Zoekt backends
- API documentation promises functionality that Zoekt doesn't deliver
Proposed solution
- Remove the hardcoded
CONTEXT_LINES_COUNTconstant - Pass the
num_context_linesparameter from the API request to the Zoekt search request - Apply the same validation/clamping logic as Elasticsearch (0 to
MAX_NUM_CONTEXT_LINES)
Related
- API documentation:
num_context_linesparameter is documented as available for "advanced and exact code search" - Elasticsearch implementation: Properly respects the
num_context_linesparameter (though it has a separate bug withnum_context_lines=0)