Conversation
The configured indexer URL ends with a trailing slash, producing URLs like https://host//templates/catalogue which return 404. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request refactors URL construction in server/src/sync/indexer.rs to ensure the base indexer URL is correctly formatted by trimming trailing slashes. A review comment suggests optimizing this by moving the trimming logic outside of the pagination loop to avoid redundant operations in each iteration.
| let mut total_new = 0usize; | ||
|
|
||
| loop { | ||
| let mut url = format!("{}/templates/catalogue?limit={}", indexer_url, limit); | ||
| let base = indexer_url.trim_end_matches('/'); | ||
| let mut url = format!("{base}/templates/catalogue?limit={limit}"); |
There was a problem hiding this comment.
The indexer_url is trimmed inside the loop, which is inefficient as the URL base remains constant across all iterations of the pagination loop. It is better to normalize the URL once before entering the loop. Shadowing the indexer_url variable also ensures that subsequent calls (like fetch_definition later in the function) benefit from the normalized URL without needing to re-trim.
| let mut total_new = 0usize; | |
| loop { | |
| let mut url = format!("{}/templates/catalogue?limit={}", indexer_url, limit); | |
| let base = indexer_url.trim_end_matches('/'); | |
| let mut url = format!("{base}/templates/catalogue?limit={limit}"); | |
| let mut total_new = 0usize; | |
| let indexer_url = indexer_url.trim_end_matches('/'); | |
| loop { | |
| let mut url = format!("{indexer_url}/templates/catalogue?limit={limit}"); |
Summary
https://host//templates/catalogue)/, and the format string adds another, producing an invalid pathindexer_urlin bothsync_onceandfetch_definitionTest plan
--network esmeraldaand verify no 404 errors in logs🤖 Generated with Claude Code