Skip to content

cortex git commit: AttributeError 'NoneType' in resolve_repo_root (Windows + path with accented chars) #27

Description

@Gabriel-Urzeda

Summary

cortex git commit crashes with AttributeError: 'NoneType' object has no attribute 'strip' in resolve_repo_root when invoked from a valid git repository working tree.

Reproduction

$ cd /path/to/any/git/repo
$ git rev-parse --is-inside-work-tree
true
$ git rev-parse --show-toplevel
C:/path/to/repo
$ cortex git commit "test message" some-file.txt

Actual behavior

File "C:\Users\Gabriel\pipx\venvs\claude-cortex\Lib\site-packages\claude_ctx_py\git\commit.py", line 144, in git_commit
    repo_root, err = resolve_repo_root(cwd)
                     ~~~~~~~~~~~~~~~~~^^^^^
  File "C:\Users\Gabriel\pipx\venvs\claude-cortex\Lib\site-packages\claude_ctx_py\git\run.py", line 47, in resolve_repo_root
    root = out.strip()
           ^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'strip'

The same error happens regardless of file count, message length, or whether files are quoted.

Expected behavior

Either successful staging+commit, or a clear error if the cwd resolution truly failed.

Root cause hypothesis (from stack trace)

resolve_repo_root(cwd) in claude_ctx_py/git/run.py:47 does root = out.strip() but out is None — likely because the subprocess call that should produce stdout for git rev-parse --show-toplevel either captures stdout as None or fails to populate it. The function probably needs:

if out is None:
    return None, "git rev-parse failed"
root = out.strip()

Direct git rev-parse --show-toplevel from the same cwd works fine (returns the path), so the wrapper that captures it inside cortex is dropping the output. Could be related to:

  • Subprocess stdout capture on Windows (cp1252 encoding edge cases?)
  • Path with non-ASCII characters in the cwd (the repo path contains "Área" with accented A)

Environment

  • OS: Windows 11 Pro 26200
  • Shell: Git Bash (MSYS2) / PowerShell — bug reproduces in both
  • Python: 3.13.13 (pipx managed venv)
  • claude-cortex version: 4.4.3 (pipx list)
  • Repo path contains: non-ASCII char (Área de Trabalho) — may be related

Workaround

Falling back to direct git add + git commit works without issues.

Minimal info to investigate

Stack trace shows it's purely a None-handling bug in resolve_repo_root. Adding an if out is None: return None, error branch would convert a hard crash into a clean error message that surfaces the underlying subprocess issue.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions