mem0ai / mem0ai/mem0

All 18 tests in tests/test_oss_to_platform_migrate.py fail on Windows — Windows paths are passed unescaped to `bash`

Open Beginner friendly
#6,830 0 comments 0 reactions 0 assignees View on GitHub
bug sdk-python
Dominant language
Python
Stars
65.6k
Forks
7.7k
Avg merge
2d 1h
Merged PRs (30d)
35

Description

### Component

Other

### Description

### Summary

`tests/test_oss_to_platform_migrate.py` shells out to the migration script with a native path:

```python
# tests/test_oss_to_platform_migrate.py:14
SCRIPT = Path(__file__).resolve().parents[1] / "scripts" / "oss-to-platform-migrate.sh"

# ...and then, in every test:
result = subprocess.run(
["bash", str(SCRIPT), "--auth-only", "--base-url", server.url, *args], ...
)
```

On Windows `str(SCRIPT)` is `C:\Users\...\scripts\oss-to-platform-migrate.sh`. `bash` treats each backslash as an escape character, so the argument arrives as `C:UsersasusDesktoposmem0scriptsoss-to-platform-migrate.sh` and the script is never found. Git Bash is installed and `bash` itself resolves fine — it is purely the argument that is mangled.

Two variants of the same root cause appear in the file:

* `subprocess.run(["/bin/bash", str(SCRIPT), "--help"], ...)` (line 542) hardcodes an absolute POSIX interpreter path.
* `subprocess.run(["bash", "-c", f"curl -fsSL file://{SCRIPT} | bash -s -- --help"], ...)` (line 557) interpolates the same backslash path into a `file://` URL.

The fix is one place — normalise the script path for the shell (`SCRIPT.as_posix()`, or resolve through `shutil.which("bash")` and pass a POSIX-form path) — rather than 18 call sites.

This is a different failure from #6719 (which is an assertion on `os.system`'s POSIX module name in the unpickler test); that one is a wrong expected value, this one is argument marshalling to a subprocess.

### Steps to Reproduce

```python
# On Windows, with Git Bash on PATH, from the repo root:
#
# python -m pytest tests/test_oss_to_platform_migrate.py -q
#
# Minimal isolation of the root cause:

import subprocess
from pathlib import Path

SCRIPT = Path("scripts/oss-to-platform-migrate.sh").resolve()

native = subprocess.run(["bash", str(SCRIPT), "--help"], capture_output=True, text=True)
print("native path ->", native.returncode, native.stderr.strip())

posix = subprocess.run(["bash", SCRIPT.as_posix(), "--help"], capture_output=True, text=True)
print("posix path ->", posix.returncode)
```

### Expected Behavior

The module's tests pass on Windows the same way they do on Linux/macOS, or they are skipped with a clear marker if a POSIX shell is a hard requirement. `bash` receives a path it can actually open.

### Actual Behavior

Every test in the module fails with the same mangled-path error:

```
> assert result.returncode == 0, result.stderr
E AssertionError: /bin/bash: C:UsersasusDesktoposmem0scriptsoss-to-platform-migrate.sh: No such file or directory
E
E assert 127 == 0
E + where 127 = CompletedProcess(args=['bash', 'C:\\Users\\asus\\Desktop\\os\\mem0\\scripts\\oss-to-platform-migrate.sh', ...],
E stdout='', stderr='/bin/bash: C:UsersasusDesktoposmem0scriptsoss-to-platform-migrate.sh: No such file or directory\n')

tests\test_oss_to_platform_migrate.py:828: AssertionError
```

Summary from a full run of the core suite:

```
FAILED tests/test_oss_to_platform_migrate.py::test_existing_api_key_authenticates_and_stitches_ids
FAILED tests/test_oss_to_platform_migrate.py::test_email_code_authenticates_without_persisting_credentials
FAILED tests/test_oss_to_platform_migrate.py::test_invalid_stored_key_falls_back_to_email_code
FAILED tests/test_oss_to_platform_migrate.py::test_email_code_failure_reports_failed_telemetry
FAILED tests/test_oss_to_platform_migrate.py::test_malformed_config_does_not_crash_and_authenticates
FAILED tests/test_oss_to_platform_migrate.py::test_weird_telemetry_shape_does_not_crash
FAILED tests/test_oss_to_platform_migrate.py::test_missing_python3_prints_clear_shell_error
FAILED tests/test_oss_to_platform_migrate.py::test_curl_piped_help_works
FAILED tests/test_oss_to_platform_migrate.py::test_export_qdrant_memories_to_json_without_vectors_or_api_key
FAILED tests/test_oss_to_platform_migrate.py::test_export_requires_scope_or_all
FAILED tests/test_oss_to_platform_migrate.py::test_export_all_uses_no_qdrant_filter
FAILED tests/test_oss_to_platform_migrate.py::test_export_invalid_qdrant_credentials_fail_clearly
FAILED tests/test_oss_to_platform_migrate.py::test_import_platform_memories_from_export_json
FAILED tests/test_oss_to_platform_migrate.py::test_import_skips_existing_identical_memory
FAILED tests/test_oss_to_platform_migrate.py::test_import_reports_changed_existing_without_update_or_add
FAILED tests/test_oss_to_platform_migrate.py::test_full_flow_auth_export_and_imports_memories
```

### Environment

* mem0 version: 2.0.17 (`main` @ 12c47f52)
* Python/Node version: Python 3.11.9
* OS: Windows 11 (Git Bash on PATH)

Contributor guide

Open the contributing guide

Research direction

Start in tests/test_oss_to_platform_migrate.py, especially the SCRIPT definition and the subprocess calls around lines 542 and 557. Run python -m pytest tests/test_oss_to_platform_migrate.py -q on Windows with Git Bash available, then make the script path usable by bash consistently and verify the module passes or skips clearly when the shell is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, python
Domain
operating-systems, testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.