Skip to content

fix(temporal): prevent panic on multi-byte UTF-8 queries#24

Open
majkelooo wants to merge 1 commit intodevwhodevs:mainfrom
majkelooo:fix/utf8-temporal-panic
Open

fix(temporal): prevent panic on multi-byte UTF-8 queries#24
majkelooo wants to merge 1 commit intodevwhodevs:mainfrom
majkelooo:fix/utf8-temporal-panic

Conversation

@majkelooo
Copy link
Copy Markdown

Summary

  • find_iso_date_in_query() in src/temporal.rs iterates over byte indices (bytes.len()) but then slices &str using those indices (&query[i..i + 10])
  • When the query contains multi-byte UTF-8 characters (e.g. Polish diacritics: ą, ś, ź, ż — each 2 bytes), a byte index can land inside a character, causing a panic at runtime
  • Added is_char_boundary() guards before slicing to skip non-boundary positions

Reproducer

engraph search "powiązania między klientami"
# panicked at src/temporal.rs:279:31:
# byte index 5 is not a char boundary; it is inside 'ą'

Any query containing Polish, Czech, German (ü, ö), or other non-ASCII characters at specific byte offsets triggers this.

Fix

for i in 0..=bytes.len() - 10 {
    if !query.is_char_boundary(i) || !query.is_char_boundary(i + 10) {
        continue;
    }
    let candidate = &query[i..i + 10];

Test plan

  • engraph search "powiązania między klientami" — was panic, now returns results
  • engraph search "księgowość rozliczenia" — was panic, now returns results
  • engraph search "świadczenie usług" — was panic, now returns results
  • ASCII queries still work as before
  • cargo build --release passes

🤖 Generated with Claude Code

`find_iso_date_in_query` iterates byte indices but slices `&str`,
which panics when an index falls inside a multi-byte character
(e.g. Polish ą, ś, ź, ż). Add `is_char_boundary` guards before
slicing.

Reproducer: `engraph search "powiązania między klientami"`

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants