Description
Is there an existing issue for the same bug? (If one exists, thumbs up or comment on the issue instead).
- I have checked the existing issues.
Describe the bug and reproduction steps
Overview
The search method in FileConversationStore fails on Windows environments due to a hardcoded path separator in the logic used to extract conversation IDs. This makes the feature non-portable and unusable on
Windows.
Description
The issue is located in the following line within FileConversationStore.search():
1 conversation_ids = [
2 path.split('/')[-2]
3 for path in self.file_store.list(metadata_dir)
4 if not path.startswith(f'{metadata_dir}/.')
5 ]
This code hardcodes the forward slash (/) as the path separator. While this works correctly on Unix-like systems (Linux, macOS), it is not compatible with Windows, which uses the backslash () as its native path
separator.
When this code is executed on Windows, self.file_store.list() returns paths like conversations\conv_123\metadata.json. The path.split('/') call fails to find any forward slashes and returns the original, unsplit
string as a single-element list (e.g., ['conversations\conv_123\metadata.json']).
The subsequent attempt to access the second-to-last element via the [-2] index results in an IndexError, crashing the method.
Steps to Reproduce
- Set up and run the application on a Windows operating system.
- Create at least one conversation history so that self.file_store.list(metadata_dir) returns one or more paths.
- Call the FileConversationStore.search() method.
- The application will raise an IndexError.
Expected Behavior
The search() method should correctly parse the conversation_id from each file path, regardless of the underlying operating system. It should successfully build the list of conversation_ids and return a
ConversationMetadataResultSet.
Actual Behavior
The method crashes and throws an FileNotFound on Windows systems.
Environment
- Operating System: Windows (e.g., Windows 10, Windows 11)
- Python Version: All
Suggested Solution
The hardcoded path manipulation should be replaced with a platform-agnostic approach using Python's standard pathlib library.
Current Code:
onversation_id = path.split('/')[-2]
Proposed Fix:
from pathlib import Path
# ... inside the list comprehension ...
conversation_id = Path(path).parent.name
This change will correctly and robustly extract the parent directory's name (which corresponds to the conversation_id) on any operating system, resolving the bug. This is the idiomatic way to handle file paths
in modern Python.
OpenHands Installation
Other
OpenHands Version
No response
Model Name
No response
Operating System
None
Logs, Errors, Screenshots, and Additional Context
No response