Skip to content
This repository was archived by the owner on Jul 9, 2026. It is now read-only.

Commit 75b5964

Browse files
committed
[gobby-#14656] fix: clamp Falkor graph query offsets
1 parent bba6172 commit 75b5964

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

crates/gcode/src/falkor.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ fn clamp_limit(limit: usize) -> usize {
197197
limit.clamp(1, MAX_GRAPH_LIMIT)
198198
}
199199

200+
fn clamp_offset(offset: usize) -> usize {
201+
offset.min(MAX_GRAPH_LIMIT)
202+
}
203+
200204
fn id_list_literal(ids: &[String]) -> String {
201205
ids.iter()
202206
.map(|id| cypher_string_literal(id))
@@ -232,6 +236,7 @@ fn find_callers_query(
232236
offset: usize,
233237
limit: usize,
234238
) -> (String, HashMap<String, String>) {
239+
let offset = clamp_offset(offset);
235240
let limit = clamp_limit(limit);
236241
(
237242
format!(
@@ -251,6 +256,7 @@ fn find_usages_query(
251256
offset: usize,
252257
limit: usize,
253258
) -> (String, HashMap<String, String>) {
259+
let offset = clamp_offset(offset);
254260
let limit = clamp_limit(limit);
255261
(
256262
format!(
@@ -463,9 +469,22 @@ mod tests {
463469

464470
#[test]
465471
fn find_callers_query_interpolates_numeric_skip_and_limit() {
466-
let (query, params) = find_callers_query("project-1", "symbol-1", 17, 0);
472+
let (query, params) = find_callers_query("project-1", "symbol-1", 250, 0);
473+
474+
assert!(query.contains("SKIP 100 LIMIT 1"), "{query}");
475+
assert_no_numeric_or_list_placeholders(&query);
476+
assert_eq!(
477+
params.get("project").map(String::as_str),
478+
Some("'project-1'")
479+
);
480+
assert_eq!(params.get("id").map(String::as_str), Some("'symbol-1'"));
481+
}
482+
483+
#[test]
484+
fn find_usages_query_clamps_numeric_skip_and_limit() {
485+
let (query, params) = find_usages_query("project-1", "symbol-1", 250, 250);
467486

468-
assert!(query.contains("SKIP 17 LIMIT 1"), "{query}");
487+
assert!(query.contains("SKIP 100 LIMIT 100"), "{query}");
469488
assert_no_numeric_or_list_placeholders(&query);
470489
assert_eq!(
471490
params.get("project").map(String::as_str),

0 commit comments

Comments
 (0)