Skip to content

fix: expand tilde (~) in vision_analyze local file paths#2585

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-d58d97b5
Mar 23, 2026
Merged

fix: expand tilde (~) in vision_analyze local file paths#2585
teknium1 merged 1 commit intomainfrom
hermes/hermes-d58d97b5

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

vision_analyze failed when given paths like ~/image.png because Path('~/...') doesn't expand tilde. The tool fell through to URL validation, producing a confusing error: Invalid image source.

Fix

One-line change: wrap with os.path.expanduser() before constructing the Path object (line 245 of vision_tools.py).

Tests

Added two tests:

  • test_tilde_path_expanded_to_local_file — verifies ~/image.png resolves and analyzes successfully
  • test_tilde_path_nonexistent_file_gives_error — verifies graceful error for ~/nonexistent.png

All 45 vision tool tests pass.

Path('~/.hermes/image.png').is_file() returns False because Path
doesn't expand tilde. This caused the tool to fall through to URL
validation, which also failed, producing a confusing error:
'Invalid image source. Provide an HTTP/HTTPS URL or a valid local
file path.'

Fix: use os.path.expanduser() before constructing the Path object.
Added two tests for tilde expansion (success and nonexistent file).
@teknium1 teknium1 merged commit b072737 into main Mar 23, 2026
1 check passed
outsourc-e pushed a commit to outsourc-e/hermes-agent that referenced this pull request Mar 26, 2026
…h#2585)

Path('~/.hermes/image.png').is_file() returns False because Path
doesn't expand tilde. This caused the tool to fall through to URL
validation, which also failed, producing a confusing error:
'Invalid image source. Provide an HTTP/HTTPS URL or a valid local
file path.'

Fix: use os.path.expanduser() before constructing the Path object.
Added two tests for tilde expansion (success and nonexistent file).
aashizpoudel pushed a commit to aashizpoudel/hermes-agent that referenced this pull request Mar 30, 2026
…h#2585)

Path('~/.hermes/image.png').is_file() returns False because Path
doesn't expand tilde. This caused the tool to fall through to URL
validation, which also failed, producing a confusing error:
'Invalid image source. Provide an HTTP/HTTPS URL or a valid local
file path.'

Fix: use os.path.expanduser() before constructing the Path object.
Added two tests for tilde expansion (success and nonexistent file).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant