Skip to content

fix: /files/matches hangs when search path includes /dev - #192

Open
Alex72-py wants to merge 7 commits into
open-webui:mainfrom
Alex72-py:fix/files-matches-dev-hang
Open

Alex72-py wants to merge 7 commits into
open-webui:mainfrom
Alex72-py:fix/files-matches-dev-hang

Conversation

@Alex72-py

@Alex72-py Alex72-py commented Oct 21, 2026 •

Copy link
Copy Markdown

Fixes #185.

GET /files/matches never returned when the search directory contained /dev (e.g. path=/). ripgrep was given the whole target directory and read device nodes, which block forever. The Python fallback also opened every listed entry.

Changes

  • utils/search.py: add --one-file-system to the rg arguments in matching_files.
  • utils/search.py: walk_entries skips directories on a different device than the search root (skips /dev, /proc, /sys).
  • utils/search.py: new is_regular_file() helper (stat.S_ISREG).
  • main.py: match_files only reads content from regular files, so device nodes, FIFOs and sockets are never opened (also covers path=/dev given directly).
  • Tests in tests/ (13), a Tests GitHub Actions workflow (Python 3.11 and 3.12, ripgrep installed), and a changelog entry under [Unreleased].

Testing

  • python -m pytest -q tests: 13 passed.
  • Before/after checks: path=/dev and a FIFO with no writer timed out on the old Python fallback but returned promptly with this change. The FIFO regression was not reproduced with ripgrep; the reported ripgrep hang on /dev was not reproduced in this environment.
  • End to end against /files/matches on a Linux sandbox: searches of / complete with this branch, taking 8.93s as root and 39.37s as a normal user with ripgrep, and 41.56s as root and 44.84s as a normal user with the Python fallback. The old Python fallback timed out on / after 45s.
  • CI: Python 3.11 and 3.12 test jobs passed on the contributor fork.
  • Environment limitation: testing used Ubuntu 24.04/KVM with ripgrep 14.1.0, not the reporter's Debian 13/LXC environment with ripgrep 14.1.1. The exact reported ripgrep hang remains unverified.

See the verification comment below for detailed timings and CI links.

The docs note about recommending ripgrep from the issue is not included.

Searching a directory that contains /dev (e.g. path=/) never returned
because ripgrep walked the whole target and read device nodes, and the
Python fallback opened every listed file.

- rg: add --one-file-system
- walk_entries: skip directories on a different device than the root
- match_files: only read regular files (is_regular_file / S_ISREG)

Fixes open-webui#185
…s and CI workflow

Covers issue open-webui#185: FIFO stand-in for blocking device nodes (Python fallback and
ripgrep paths), device-boundary skipping in walk_entries, --one-file-system being
passed to ripgrep, and is_regular_file. Adds a GitHub Actions workflow that runs
pytest with ripgrep installed.
@Alex72-py

Copy link
Copy Markdown
Author

Verification results and CI evidence

I reran the before/after sandbox checks against base 3b80fc6 and fix 1fd3dc7 in Ubuntu 24.04/KVM with ripgrep 14.1.0.

GitHub Actions on the fork

Before/after regression checks

  • path=/dev, Python fallback: base timed out after >15s; fix returned HTTP 200 in ~0.03s.
  • path=/dev, ripgrep: completed on both base and fix; the reporter's ripgrep hang was not reproduced.
  • path=/, ripgrep: base exceeded 45s; fix returned HTTP 200 in 8.93s as root and 39.37s as a normal user.
  • path=/, Python fallback: base exceeded 45s; fix returned HTTP 200 in 41.56s as root and 44.84s as a normal user.
  • FIFO with no writer, Python fallback: base timed out after >15s; fix returned HTTP 200 in 0.024s.
  • FIFO with no writer, ripgrep: passed on both base and fix.

Limitation

The reporter's exact Debian 13/LXC + ripgrep 14.1.1 /dev failure remains unreproduced. These tests used Ubuntu 24.04/KVM + ripgrep 14.1.0. Searching from / now completes, but the Python fallback can still take about 45 seconds in this sandbox.

@Alex72-py

Copy link
Copy Markdown
Author

Hi @tjbck, would you be able to review this PR when you have a chance? Thanks!

This branch has not been deployed

No deployments
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.

File search (/files/matches) hangs when the search path includes /dev, e.g. path=/

1 participant