Skip to content

fix: keep customer content out of loguru message formatting during index retries - #1216

Merged
phernandez merged 1 commit into
mainfrom
issue-1212-loguru-brace-safety
Aug 9, 2026
Merged

fix: keep customer content out of loguru message formatting during index retries#1216
phernandez merged 1 commit into
mainfrom
issue-1212-loguru-brace-safety

Conversation

@phernandez

Copy link
Copy Markdown
Member

Why

Index retry jobs can reach Loguru with customer-derived note paths already interpolated into the
message template. When a path contains literal braces such as {AG}, Loguru treats the customer
text as a formatting field and raises KeyError, preventing the note from indexing across every
identical job attempt.

Closes #1212

What Changed

  • pass customer-derived paths as positional Loguru arguments in both per-file markdown retry loops
  • apply the same brace-safe pattern to sibling regular-file and markdown debug log calls in the
    two audited indexing modules
  • cover both reachable retry loops with real Loguru rendering and brace-bearing filename/title
    regressions

Implementation Details

The log messages now use static templates and provide paths as positional arguments, which Loguru
formats once without interpreting braces inside the argument value. Existing structured context
such as entity IDs, checksums, operations, and graph counts remains attached to each record. This
is intentionally a call-site fix rather than a logging wrapper or content sanitizer.

Testing

Automated

  • uv run pytest tests/indexing/test_file_indexer.py tests/index/test_local_markdown_file_indexer.py -q: 12 passed
  • just fast-check: passed (Ruff fix/format and ty typecheck)
  • just fast-test: 5,116 passed, 41 skipped
  • just doctor: passed

Manual

  • reproduced the pre-fix distinction directly with Loguru: positional notes/{AG}.md rendered,
    while the interpolated success template raised KeyError: 'AG'
  • audited both changed modules and confirmed no Loguru call still uses an f-string template

Risks / Follow-ups

The change affects logging argument construction only; indexing control flow and persisted data are
unchanged. Production should be monitored for recurrence of the two Logfire issue cohorts cited in
#1212 after deployment.

Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez
phernandez merged commit e8548bf into main Aug 9, 2026
25 checks passed
@phernandez
phernandez deleted the issue-1212-loguru-brace-safety branch August 9, 2026 17:19
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.

Indexing crashes with KeyError when note content reaches loguru message formatting

1 participant