Skip to content

Conversation

@ezyang
Copy link
Owner

@ezyang ezyang commented Apr 15, 2025

Stack from ghstack (oldest at bottom):

We sometimes fail to get current commit hash. This is because we improperly pass a file rather than directory to the git command. Here is a representative warning:
2025-04-14 21:31:31,930 - root - WARNING - Exception when getting current commit hash: [Errno 20] Not a directory: '/Users/ezyang/Dev/codemcp/codemcp/agno.py'
Traceback (most recent call last):
File "/Users/ezyang/Dev/codemcp/codemcp/git_query.py", line 279, in get_current_commit_hash
result = await run_command(
^^^^^^^^^^^^^^^^^^
File "/Users/ezyang/Dev/codemcp/codemcp/shell.py", line 73, in run_command
process = await asyncio.create_subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/subprocess.py", line 224, in create_subprocess_exec
transport, protocol = await loop.subprocess_exec(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 1756, in subprocess_exec
transport = await self._make_subprocess_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/unix_events.py", line 211, in makesubprocess_transport
transp = _UnixSubprocessTransport(self, protocol, args, shell,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/base_subprocess.py", line 36, in init
self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/unix_events.py", line 820, in _start
self._proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/subprocess.py", line 1028, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/subprocess.py", line 1963, in executechild
raise child_exception_type(errno_num, err_msg, err_filename)
NotADirectoryError: [Errno 20] Not a directory: '/Users/ezyang/Dev/codemcp/codemcp/agno.py'
Convert this warning into a hard error, and add a test which triggers the failure. I want a NATURAL test that exercises codemcp itself similar to the E2E tests, not a unit test that manually calls the function and triggers an error. Hypothesize how you could get to this error state in the existing codebase before writing the test.

64397ca  (Base revision)
641e6f4  Convert NotADirectoryError from warning to hard error
56fe41e  Add E2E test for file path vs. directory error
00043d5  Add explicit file path check in git_log tool
c6930d5  Add missing os import in git_log.py
3663dec  Add os import to git_diff.py
780c82c  Add explicit file path check in git_diff tool
d1737e0  Add os import to git_show.py
00ca5e8  Add explicit file path check in git_show tool
ec6cc53  Add os import to git_blame.py
a233448  Add explicit file path check in git_blame tool
871f76e  Auto-commit format changes
abdbc58  Auto-commit lint changes
37b1af5  Replace expecttest import with unittest
7b0b731  Replace expecttest decorator with unittest.expectedFailure
6a34291  Fix test to use RunCommand instead of GitLog
cfa3f0e  Fix test_git_diff_with_file_path to use RunCommand
a3f9a14  Fix test_git_show_with_file_path to use RunCommand
c792464  Replace assertion in first test method
eb397ab  Replace assertion in second test method
f5149e9  Replace assertion in third test method
ab28ea4  Update comment in first test
b64c375  Rename and update second test method
89550e7  Rename and update third test method
c2dfb6f  Update comment in second test
1d0854c  Update comment in third test
cfb93d7  Update assertion in first test
1915f6b  Update assertion in second test
340aaf5  Update assertion in last test
17ac6a3  Remove expectedFailure decorator since test is now passing
52f884b  Rename second test method to be more accurate
HEAD     Auto-commit lint changes

codemcp-id: 266-fix-convert-git-directory-error-to-hard-error-and-

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Apr 15, 2025
We sometimes fail to get current commit hash. This is because we improperly pass a file rather than directory to the git command. Here is a representative warning:
2025-04-14 21:31:31,930 - root - WARNING - Exception when getting current commit hash: [Errno 20] Not a directory: '/Users/ezyang/Dev/codemcp/codemcp/agno.py'
Traceback (most recent call last):
  File "/Users/ezyang/Dev/codemcp/codemcp/git_query.py", line 279, in get_current_commit_hash
    result = await run_command(
             ^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/Dev/codemcp/codemcp/shell.py", line 73, in run_command
    process = await asyncio.create_subprocess_exec(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/subprocess.py", line 224, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 1756, in subprocess_exec
    transport = await self._make_subprocess_transport(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/unix_events.py", line 211, in *make*subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/base_subprocess.py", line 36, in **init**
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/unix_events.py", line 820, in _start
    self._proc = subprocess.Popen(
                 ^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/subprocess.py", line 1028, in **init**
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/subprocess.py", line 1963, in *execute*child
    raise child_exception_type(errno_num, err_msg, err_filename)
NotADirectoryError: [Errno 20] Not a directory: '/Users/ezyang/Dev/codemcp/codemcp/agno.py'
Convert this warning into a hard error, and add a test which triggers the failure. I want a NATURAL test that exercises codemcp itself similar to the E2E tests, not a unit test that manually calls the function and triggers an error. Hypothesize how you could get to this error state in the existing codebase before writing the test.

```git-revs
64397ca  (Base revision)
641e6f4  Convert NotADirectoryError from warning to hard error
56fe41e  Add E2E test for file path vs. directory error
00043d5  Add explicit file path check in git_log tool
c6930d5  Add missing os import in git_log.py
3663dec  Add os import to git_diff.py
780c82c  Add explicit file path check in git_diff tool
d1737e0  Add os import to git_show.py
00ca5e8  Add explicit file path check in git_show tool
ec6cc53  Add os import to git_blame.py
a233448  Add explicit file path check in git_blame tool
871f76e  Auto-commit format changes
abdbc58  Auto-commit lint changes
37b1af5  Replace expecttest import with unittest
7b0b731  Replace expecttest decorator with unittest.expectedFailure
6a34291  Fix test to use RunCommand instead of GitLog
cfa3f0e  Fix test_git_diff_with_file_path to use RunCommand
a3f9a14  Fix test_git_show_with_file_path to use RunCommand
c792464  Replace assertion in first test method
eb397ab  Replace assertion in second test method
f5149e9  Replace assertion in third test method
ab28ea4  Update comment in first test
b64c375  Rename and update second test method
89550e7  Rename and update third test method
c2dfb6f  Update comment in second test
1d0854c  Update comment in third test
cfb93d7  Update assertion in first test
1915f6b  Update assertion in second test
340aaf5  Update assertion in last test
17ac6a3  Remove expectedFailure decorator since test is now passing
52f884b  Rename second test method to be more accurate
HEAD     Auto-commit lint changes
```

codemcp-id: 266-fix-convert-git-directory-error-to-hard-error-and-
ghstack-source-id: edb3471
Pull-Request-resolved: #258
[ghstack-poisoned]
ezyang added a commit that referenced this pull request Apr 15, 2025
We sometimes fail to get current commit hash. This is because we improperly pass a file rather than directory to the git command. Here is a representative warning:
2025-04-14 21:31:31,930 - root - WARNING - Exception when getting current commit hash: [Errno 20] Not a directory: '/Users/ezyang/Dev/codemcp/codemcp/agno.py'
Traceback (most recent call last):
  File "/Users/ezyang/Dev/codemcp/codemcp/git_query.py", line 279, in get_current_commit_hash
    result = await run_command(
             ^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/Dev/codemcp/codemcp/shell.py", line 73, in run_command
    process = await asyncio.create_subprocess_exec(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/subprocess.py", line 224, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 1756, in subprocess_exec
    transport = await self._make_subprocess_transport(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/unix_events.py", line 211, in *make*subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/base_subprocess.py", line 36, in **init**
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/unix_events.py", line 820, in _start
    self._proc = subprocess.Popen(
                 ^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/subprocess.py", line 1028, in **init**
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/subprocess.py", line 1963, in *execute*child
    raise child_exception_type(errno_num, err_msg, err_filename)
NotADirectoryError: [Errno 20] Not a directory: '/Users/ezyang/Dev/codemcp/codemcp/agno.py'
Convert this warning into a hard error, and add a test which triggers the failure. I want a NATURAL test that exercises codemcp itself similar to the E2E tests, not a unit test that manually calls the function and triggers an error. Hypothesize how you could get to this error state in the existing codebase before writing the test.

```git-revs
64397ca  (Base revision)
641e6f4  Convert NotADirectoryError from warning to hard error
56fe41e  Add E2E test for file path vs. directory error
00043d5  Add explicit file path check in git_log tool
c6930d5  Add missing os import in git_log.py
3663dec  Add os import to git_diff.py
780c82c  Add explicit file path check in git_diff tool
d1737e0  Add os import to git_show.py
00ca5e8  Add explicit file path check in git_show tool
ec6cc53  Add os import to git_blame.py
a233448  Add explicit file path check in git_blame tool
871f76e  Auto-commit format changes
abdbc58  Auto-commit lint changes
37b1af5  Replace expecttest import with unittest
7b0b731  Replace expecttest decorator with unittest.expectedFailure
6a34291  Fix test to use RunCommand instead of GitLog
cfa3f0e  Fix test_git_diff_with_file_path to use RunCommand
a3f9a14  Fix test_git_show_with_file_path to use RunCommand
c792464  Replace assertion in first test method
eb397ab  Replace assertion in second test method
f5149e9  Replace assertion in third test method
ab28ea4  Update comment in first test
b64c375  Rename and update second test method
89550e7  Rename and update third test method
c2dfb6f  Update comment in second test
1d0854c  Update comment in third test
cfb93d7  Update assertion in first test
1915f6b  Update assertion in second test
340aaf5  Update assertion in last test
17ac6a3  Remove expectedFailure decorator since test is now passing
52f884b  Rename second test method to be more accurate
c24d978  Auto-commit lint changes
6020aa7  Add test using WriteFile with a file path
HEAD     Snapshot before auto-test
```

codemcp-id: 266-fix-convert-git-directory-error-to-hard-error-and-
ghstack-source-id: 3df9564
Pull-Request-resolved: #258
[ghstack-poisoned]
ezyang added a commit that referenced this pull request Apr 15, 2025
We sometimes fail to get current commit hash. This is because we improperly pass a file rather than directory to the git command. Here is a representative warning:
2025-04-14 21:31:31,930 - root - WARNING - Exception when getting current commit hash: [Errno 20] Not a directory: '/Users/ezyang/Dev/codemcp/codemcp/agno.py'
Traceback (most recent call last):
  File "/Users/ezyang/Dev/codemcp/codemcp/git_query.py", line 279, in get_current_commit_hash
    result = await run_command(
             ^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/Dev/codemcp/codemcp/shell.py", line 73, in run_command
    process = await asyncio.create_subprocess_exec(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/subprocess.py", line 224, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 1756, in subprocess_exec
    transport = await self._make_subprocess_transport(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/unix_events.py", line 211, in *make*subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/base_subprocess.py", line 36, in **init**
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/unix_events.py", line 820, in _start
    self._proc = subprocess.Popen(
                 ^^^^^^^^^^^^^^^^^
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/subprocess.py", line 1028, in **init**
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/ezyang/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/subprocess.py", line 1963, in *execute*child
    raise child_exception_type(errno_num, err_msg, err_filename)
NotADirectoryError: [Errno 20] Not a directory: '/Users/ezyang/Dev/codemcp/codemcp/agno.py'
Convert this warning into a hard error, and add a test which triggers the failure. I want a NATURAL test that exercises codemcp itself similar to the E2E tests, not a unit test that manually calls the function and triggers an error. Hypothesize how you could get to this error state in the existing codebase before writing the test.

```git-revs
64397ca  (Base revision)
641e6f4  Convert NotADirectoryError from warning to hard error
56fe41e  Add E2E test for file path vs. directory error
00043d5  Add explicit file path check in git_log tool
c6930d5  Add missing os import in git_log.py
3663dec  Add os import to git_diff.py
780c82c  Add explicit file path check in git_diff tool
d1737e0  Add os import to git_show.py
00ca5e8  Add explicit file path check in git_show tool
ec6cc53  Add os import to git_blame.py
a233448  Add explicit file path check in git_blame tool
871f76e  Auto-commit format changes
abdbc58  Auto-commit lint changes
37b1af5  Replace expecttest import with unittest
7b0b731  Replace expecttest decorator with unittest.expectedFailure
6a34291  Fix test to use RunCommand instead of GitLog
cfa3f0e  Fix test_git_diff_with_file_path to use RunCommand
a3f9a14  Fix test_git_show_with_file_path to use RunCommand
c792464  Replace assertion in first test method
eb397ab  Replace assertion in second test method
f5149e9  Replace assertion in third test method
ab28ea4  Update comment in first test
b64c375  Rename and update second test method
89550e7  Rename and update third test method
c2dfb6f  Update comment in second test
1d0854c  Update comment in third test
cfb93d7  Update assertion in first test
1915f6b  Update assertion in second test
340aaf5  Update assertion in last test
17ac6a3  Remove expectedFailure decorator since test is now passing
52f884b  Rename second test method to be more accurate
c24d978  Auto-commit lint changes
6020aa7  Add test using WriteFile with a file path
11cc1b4  Snapshot before auto-test
HEAD     Replace complex test with simpler WriteFile test
```

codemcp-id: 266-fix-convert-git-directory-error-to-hard-error-and-
ghstack-source-id: b67108b
Pull-Request-resolved: #258
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant