gitlabhq/gitlabhq · error · Gitlab::Graphql::Errors::ArgumentError
#{end_name} must be greater than #{start_name}
Error message
#{end_name} must be greater than #{start_name} What it means
The same validate_end_line_has_start! in LatestDiffNote also checks ordering: after confirming the start line exists, it requires end_line > start_line, otherwise it raises ArgumentError '<end> must be greater than <start>'. A range comment must span forward in the diff; equal or inverted ranges are rejected before the note is created.
Source
Thrown at app/graphql/mutations/notes/create/latest_diff_note.rb:82
private
def validate_line_range!(args)
validate_end_line_has_start!(args[:end_new_line], args[:new_line], 'newLine', 'endNewLine')
validate_end_line_has_start!(args[:end_old_line], args[:old_line], 'oldLine', 'endOldLine')
end
def validate_end_line_has_start!(end_line, start_line, start_name, end_name)
return unless end_line
unless start_line
raise Gitlab::Graphql::Errors::ArgumentError,
"#{start_name} is required when #{end_name} is provided"
end
return if end_line > start_line
raise Gitlab::Graphql::Errors::ArgumentError,
"#{end_name} must be greater than #{start_name}"
end
def create_note_params(noteable, args)
super.merge({
type: 'DiffNote',
position: position(noteable, args),
merge_request_diff_head_sha: args[:head_sha]
})
end
def position(noteable, args)
resolve_result = ::MergeRequests::ResolveDiffPositionService.new(
noteable.project,
current_user,
merge_request: noteable,
file_path: args[:file_path],
new_line: args[:new_line],View on GitHub (pinned to 55ee20384a)
Solutions
- Normalize before sending: start = Math.min(a, b); end = Math.max(a, b)
- Treat a single-row selection (start === end) as a plain line comment: send only newLine/oldLine without end* fields
- Check end > start after converting UI row indexes to diff line numbers
Example fix
// before
await gql(CREATE_NOTE, { ..., newLine: 50, endNewLine: 42 });
// after
const [start, end] = selection[0] <= selection[1]
? selection : [selection[1], selection[0]];
await gql(CREATE_NOTE, { ..., newLine: start, endNewLine: end }); Defensive patterns
Strategy: validation
Validate before calling
function normalizeRange(a, b) {
if (a == null && b == null) return null;
if (a == null || b == null) return { start: a ?? b, end: null }; // single line
return { start: Math.min(a, b), end: Math.max(a, b) > Math.min(a, b) ? Math.max(a, b) : null }; // equal -> single line
} Try / catch
On /must be greater than/, swap or normalize start/end (min/max) client-side and retry; if start === end, resend without the end* argument.
Prevention
- Normalize selection coordinates with min/max before sending
- Convert 0-based UI row indexes to 1-based diff line numbers carefully
When it happens
Trigger: Calling the mutation with newLine: 50, endNewLine: 50 (equal), or newLine: 50, endNewLine: 42 (inverted). The comparison runs right after the pairing check in ready?.
Common situations: Drag-select in a custom diff viewer that reports rows in mouse-up order regardless of direction; off-by-one when normalizing 0-based UI rows to 1-based diff lines; passing coordinates as (x, y) where the API expects (start, end).
Related errors
- #{start_name} is required when #{end_name} is provided
- position oldLine or newLine arguments are required
- oldLine or newLine arguments are required
- No object found for `id: #{id.to_s.inspect}`
- Note cannot be converted to a resolvable thread
AI-assisted analysis of gitlabhq/gitlabhq@55ee20384a (2026-08-21).
Data as JSON: /api/errors/76d243da5142252e.
Report an issue: GitHub.