Skip to content

Infinite loop occurred in build_nested_folders. #25991

Description

@andreyfedoseev

Type: Bug

Behaviour

Pytest test discovery fails with error (see the logs below).

Steps to reproduce:

My project structure is:

/my-project
  /backend
    /.venv/
    /tests/
  /frontend/...
  ...

I have the following project-level settings:

  "python.testing.cwd": "${workspaceFolder}/backend",
  "python.testing.pytestArgs": [
    "tests",
    "-vvv"
  ],

This setup worked for my for at least 6 months. It stopped working a few days ago, so it looks like a regression.

I found that some related code was changed recently in #25974

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

  File "/home/user/.vscode/extensions/ms-python.python-2026.4.0-linux-x64/python_files/vscode_pytest/__init__.py", line 817, in build_nested_folders
    raise ValueError(
    ...<4 lines>...
    )
ValueError: ('[vscode-pytest]: Infinite loop occurred in build_nested_folders. iterator_path: ', PosixPath('/'), 'session_node_path: ', PosixPath('/home/user/my-project/backend'))

Extension version: 2026.4.0
VS Code version: Code 1.119.0 (8b640eef5a6c6089c029249d48efa5c99adf7d51, 2026-05-05T11:23:50-07:00)
OS version: Linux x64 6.18.33
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.14.3
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Default
User Settings


languageServer: "Pylance"

testing
• cwd: "${workspaceFolder}/backend"
• pytestArgs: ["tests", "-vvv"]
• pytestEnabled: true

Installed Extensions
Extension Name Extension Id Version
Bookmarks ale 14.1.1
code-spell-checker str 4.5.6
code-spell-checker-russian str 2.2.4
copilot-chat Git 0.47.0
cpptools ms- 1.32.2
debugpy ms- 2026.6.0
direnv mkh 0.17.0
even-better-toml tam 0.21.2
explorer vit 1.50.4
go gol 0.52.2
hexeditor ms- 1.11.1
js-debug ms- 1.117.0
js-debug-companion ms- 1.1.3
jsts-chat-features Typ 0.0.2
material-icon-theme PKi 5.34.0
nix-env-selector arr 1.3.1
nix-ide jno 0.5.9
python ms- 2026.4.0
remote-containers ms- 0.459.0
remote-explorer ms- 0.5.0
remote-repositories ms- 0.42.0
remote-ssh ms- 0.124.0
remote-ssh-edit ms- 0.87.0
remotehub Git 0.64.0
rest-client hum 0.25.1
rewrap-revived dnu 1.16.3
ruff cha 2026.46.0
rust-analyzer rus 0.3.2921
sqlite-viewer qwt 25.12.2
volar Vue 3.3.3
vscode-containers ms- 2.4.5
vscode-edit-csv jan 0.11.9
vscode-eslint dba 3.0.24
vscode-icons vsc 12.18.0
vscode-js-profile-table ms- 1.0.10
vscode-just-syntax nef 0.10.1
vscode-markdownlint Dav 0.61.2
vscode-pull-request-github Git 0.144.0
vscode-pylance ms- 2026.2.1
vscode-python-envs ms- 1.30.0
vscode-tailwindcss bra 0.14.29

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions