fix: tolerate non-utf8 filenames in file discovery - #12932
Conversation
|
Maintainer context: I did a repo search for related Related but distinct items:
This PR is intentionally scoped to a different failure surface:
So it is in the same bug family, but it is not trying to reopen the migration or Windows-stdio fixes. |
|
Maintainer note: this fork-based PR has focused local verification already completed:
Current blocker appears to be GitHub Actions approval for fork workflows: the PR checks are showing If a maintainer approves / runs the PR workflows in the GitHub UI, I can follow up on any real CI failures after that. |
|
@kshitijk4poor @teknium1 friendly ping on this bugfix as well: it is a small, focused fix for non-UTF-8 filename handling in CLI file discovery/context expansion, with regression coverage already in place. Current blocker seems to be fork-workflow approval ( |
0dec17f to
a7df9f0
Compare
|
Refresh update: I merged current Updated head: Focused local verification on the refreshed branch:
The PR is mergeable again locally / via GitHub metadata. The current GitHub Actions runs on the refreshed head still show |
|
Refresh update: I merged current Updated head: Focused local verification on the refreshed head:
GitHub now reports the PR as mergeable again. The new workflow runs are still at the fork workflow approval gate ( |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused filesystem-decoding fix. The context-reference premise is present on current main: agent/context_references.py:533-547 runs rg --files with text=True, and the proposed byte/os.fsdecode conversion is the right direction.
Problems
tests/hermes_cli/test_path_completion.py:187does not prove the classic CLI fix. Current main useserrors="replace"athermes_cli/commands.py:1662-1667, so an unusable@file:bad-�.txtcompletion still passes thestartswith("@file:bad-")assertion. Assert that the returned filename suffix round-trips throughos.fsencodetob"bad-\xff.txt".- The matching TUI path remains affected:
ui-tui/src/hooks/useCompletion.ts:34-37routes@completion tocomplete.path, whiletui_gateway/server.py:12361,12380UTF-8 replacement-decodesgitpath output. Please include byte-safe decoding and regression coverage there as well.
Automated hermes-sweeper review.
| completions = list(completer.get_completions(doc, event)) | ||
| texts = [completion.text for completion in completions] | ||
| assert "@file:good.txt" in texts | ||
| assert any(text.startswith("@file:bad-") for text in texts) |
There was a problem hiding this comment.
This only checks the prefix. Current main decodes rg output with errors="replace" (hermes_cli/commands.py:1662-1667), so it produces @file:bad-�.txt and this assertion still passes. Assert an os.fsencode() round-trip of the path suffix to prove surrogateescape preservation.
120d836 to
dc44cef
Compare
|
Thanks — addressed on the current head
Focused verification on the updated head: Could you please re-review the updated head? |
Summary
@completionWhy
Some repositories contain filenames that are valid on the filesystem but not valid UTF-8. Hermes should not crash when scanning those trees for
@file completion or folder context references.Root cause
subprocess.run(..., text=True)decodedrg --filesoutput as strict UTF-8. If the working tree contained non-UTF-8 filenames, Hermes raisedUnicodeDecodeErrorwhile building completions or folder listings.Behavior before
@completion could crash on mixed-encoding treesrg --filesreturned non-UTF-8 namesBehavior after
text=Falseos.fsdecode(...), preserving filesystem semantics via surrogateescapeHow to test
python -m pytest tests/hermes_cli/test_path_completion.py tests/agent/test_context_references.py -o 'addopts=' -q@completion no longer crashesPlatforms tested
Related issues / PRs
UnicodeDecodeErrorin real-world environments.Notes