AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Test_mset_chmod Fails On Windows Due To Unsupported Chmod Permission Bits

The unit test test_mset_chmod in tests/unit_tests/storage/test_filesystem.py fails on Windows because Windows does not support POSIX-style group and other chmod permission bits, causing assertion mismatches for modes 0o770 and 0o700.

mediumConfidence 90%LangchainAffected V1.0.8

Origin Analysis

On Windows, os.chmod only enforces the read-only attribute (S_IWRITE). Group and other permission bits are ignored. The test asserts exact POSIX mode bits returned by os.stat, which on Windows reports a synthetic mode (often 0o777) that does not match the requested chmod value, leading to assertion failures.
cd libs/langchain uv sync --all-groups uv run --group test pytest tests/unit_tests/storage/test_filesystem.py -v

Fixing Code Block

import os import stat import sys import tempfile import pytest from langchain_classic.storage.file_system import LocalFileStore @pytest.mark.skipif( sys.platform == "win32", reason="POSIX chmod permissions are not supported on Windows", ) @pytest.mark.parametrize( "chmod_val, expected", [(0o770, 0o660), (0o700, 0o600)], ) def test_mset_chmod(chmod_val, expected): with tempfile.TemporaryDirectory() as temp_dir: store = LocalFileStore(temp_dir, chmod=chmod_val) store.mset([("key1", b"value1")]) file_path = os.path.join(temp_dir, "key1") file_mode = stat.S_IMODE(os.stat(file_path).st_mode) assert file_mode == expected
The test is skipped on Windows because the underlying OS does not implement POSIX group/other permission bits; asserting exact octal modes is meaningless on that platform. The skip prevents false failures while preserving full coverage on Unix-like systems.

Edge Case Audit

This change only affects test execution on Windows; production code is unchanged. If a future Windows version adds POSIX permission support, the skip may hide real regressions. No rollback risk, but if the test suite is used to enforce chmod behavior across platforms, consider adding a separate Windows-specific test that checks only the read-only flag.

Ecosystem Topology