Skip to content

fix: catch NotImplementedError from Path.glob() with non-relative patterns#5405

Open
Sarthak816 wants to merge 7 commits into
Aider-AI:mainfrom
Sarthak816:fix/5404-pathlib-notimplementederror
Open

fix: catch NotImplementedError from Path.glob() with non-relative patterns#5405
Sarthak816 wants to merge 7 commits into
Aider-AI:mainfrom
Sarthak816:fix/5404-pathlib-notimplementederror

Conversation

@Sarthak816

Copy link
Copy Markdown

Fixes #5404 - Uncaught NotImplementedError in pathlib.py line 949

When using /read-only (or similar commands) with glob patterns containing .. or non-relative components, Python 3.11+'s Path.glob() raises NotImplementedError('Non-relative patterns are unsupported') because parse_parts() detects a rooted component.

Changes in aider/commands.py:

  1. cmd_read_only — Wrapped Path(self.coder.root).glob(expanded_pattern) in try/except NotImplementedError, falling back to glob.glob() which accepts any pattern when given an absolute base path. Added recursive=True so ** patterns work in the fallback path.

  2. glob_filtered_to_repo — Added NotImplementedError to the existing except (IndexError, AttributeError) tuple as a defensive catch for the same issue.

Fixes Aider-AI#5307 - on OpenBSD and other platforms without pre-built wheels, tree-sitter-c-sharp builds from source. Versions 0.23.1-0.23.4 do not bundle the tree_sitter/parser.h header, causing the C compiler to fail with 'fatal error: tree_sitter/parser.h not found'.

Updated tree-sitter-c-sharp to 0.23.5 which includes the necessary headers for source builds.

Changes:
- requirements.txt: 0.23.1 -> 0.23.5
- requirements/common-constraints.txt: 0.23.1 -> 0.23.5
- requirements/tree-sitter.in: added tree-sitter-c-sharp>=0.23.5 constraint with explanatory comment
Fixes Aider-AI#5358 - adds type annotations to all public functions across 4 core modules:

- aider/main.py: ~20 functions typed (entry points, argument parsing, git setup)
- aider/commands.py: ~45 methods typed (all user-facing / commands + helpers)
- aider/io.py: ~25 methods typed (InputOutput class + helpers)
- aider/models.py: ~40 methods typed (ModelInfoManager, Model class, module-level functions)

Key implementation decisions:
- Added from __future__ import annotations to all files for forward reference support
- Used Optional, Union, Any, Callable, TextIO from typing as appropriate
- NoRuntime for functions that always raise exceptions (Sys.exit, SwitchCoder)
- Used None return type for functions that sometimes return and sometimes raise
Fixes Aider-AI#5376 - Aider was silently bypassing pre-commit hooks by applying --no-verify to all git commits. This is a security risk for projects relying on pre-commit hooks for SAST scanning, secret detection, and code formatting.

Changed the default of --git-commit-verify from False to True in aider/args.py, so pre-commit hooks are now honored by default. Users who need to bypass hooks can explicitly opt in with --no-git-commit-verify.
Fixes Aider-AI#5375 - Remote Code Execution via unescaped cmd parameter with shell=True

Changes:

1. aider/run_cmd.py:
   - Added _has_shell_operators() helper that detects shell metacharacters outside of quoted strings
   - Modified run_cmd_subprocess to prefer list-based subprocess execution (shell=False) for commands without shell operators
   - Falls back to shell=True only for commands containing pipes, redirects, chaining, or other shell features

2. aider/commands.py:
   - Modified cmd_git() to use shlex.split() + list-based subprocess.run with shell=False
   - Git commands don't need shell features, so shell=True was unnecessary
…o terminal

Fixes Aider-AI#5396 - Ollama reasoning models (e.g. Qwen3.6) embed <think> reasoning blocks in the regular content field rather than the reasoning_content field, causing raw XML in terminal output and corrupted formatting.

Changes:

1. aider/coders/base_coder.py:
   - Added _normalize_think_tags() helper that converts raw <think> tags to the internal REASONING_TAG format when reasoning_tag_name != 'think'
   - Applied in show_send_output_stream (streaming path) before accumulation and display
   - Applied in show_send_output (non-streaming path) before display
   - Applied in remove_reasoning_content as a safety net before stripping

2. aider/models.py:
   - Added generic settings for Ollama reasoning models (qwq, r1, reasoning, think, deepseek, qwen3) to set reasoning_tag='think' with appropriate defaults
Fixes Aider-AI#5393 - Uncaught ImportError when scipy's native _spropack binary fails to load on macOS (section __DATA/__thread_bss linker issue).

networkx 3.x's pagerank() calls _pagerank_scipy() directly with no try/except fallback. When scipy's deep import chain fails (e.g. _svdp.py -> _propack._spropack.so), the ImportError propagates uncaught.

Added except (ImportError, OSError) around nx.pagerank() that falls back to networkx's pure-Python _pagerank_python implementation. User gets warning messages in both the fallback and failure paths.
…terns

Fixes Aider-AI#5404 - Uncaught NotImplementedError in pathlib.py line 949 when using /read-only with patterns containing '..' or other non-relative components (Python 3.11+).

Changes in aider/commands.py:
1. cmd_read_only: Wrapped Path(self.coder.root).glob() in try/except NotImplementedError, falling back to glob.glob() with recursive=True
2. glob_filtered_to_repo: Added NotImplementedError to the existing except tuple
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.

Uncaught NotImplementedError in pathlib.py line 949

1 participant