fix(hat): don't rename to a stem-less dotfile on a degenerate model answer#32
Merged
Merged
Conversation
…nswer `sanitize_name` appended the original extension unconditionally, so an empty or unusable answer (e.g. a reasoning model that spent its whole budget inside <think> and emitted no name, or punctuation like "." / "/") produced a stem-less name like ".jpg". That's non-empty, so it slips past the caller's `-z "$suggested"` guard and renames the file to a hidden, stem-less file — effectively losing it. Strip leftover dots/dashes from the stem and, if nothing remains, emit no name so the empty-guard rejects the rename and reports "(no suggestion)". Adds 3 regression tests (empty / think-only / punctuation-only → no name). All 80 bats tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
marksverdhei
added a commit
that referenced
this pull request
Jun 27, 2026
Adds (newest first, matching existing style): - #32 stem-less dotfile guard - #30 video file support - #28 --preview / -p flag - #27 is_audio ftyp false-positive fix - #20 audio file support Skipped pure-docs (#15, #16, #17, #31), CI infra (#29), and test-only rebases (#25) — same selection rule the prior entries used.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
sanitize_nameappends the original extension unconditionally:So when the model returns nothing usable — an empty answer, a think-only answer (a reasoning model that spent its budget inside
<think>and emitted no name), or punctuation like.//— the result is a stem-less name like.jpg:That's non-empty, so it slips past the caller's
[[ -z "$suggested" ]]guard (hat:991) and renames the user's file to a hidden, stem-less file — effectively losing it.Fix
Strip leftover dots/dashes from the stem; if nothing remains, emit no name so the empty-guard rejects the rename and reports
(no suggestion):Tests
3 regression tests (empty / think-only / punctuation-only →
""). They fail on the old code (actual: .jpg) and pass with the fix. All existing sanitize cases unchanged. 80/80 bats pass.🤖 Generated with Claude Code