Skip to content

fix: strip trailing slash from indexer URL#8

Merged
sdbondi merged 1 commit intomainfrom
minor-fixes
Apr 10, 2026
Merged

fix: strip trailing slash from indexer URL#8
sdbondi merged 1 commit intomainfrom
minor-fixes

Conversation

@sdbondi
Copy link
Copy Markdown
Member

@sdbondi sdbondi commented Apr 10, 2026

Summary

  • Fix 404 errors in the indexer sync loop caused by a double-slash in the URL (https://host//templates/catalogue)
  • The configured indexer URL ends with /, and the format string adds another, producing an invalid path
  • Trim trailing slash from indexer_url in both sync_once and fetch_definition

Test plan

  • Run with --network esmeralda and verify no 404 errors in logs
  • Verify sync loop successfully fetches catalogue entries

🤖 Generated with Claude Code

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>
@sdbondi sdbondi merged commit bb9ed78 into main Apr 10, 2026
4 checks passed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 58 to +62
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}");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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}");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant