Skip to content

SearXNG migration tests execute POSIX-only paths on Windows #6067

Description

@RaresKeY

Prerequisites

  • I searched open and closed issues, open pull requests, and discussions for migrate_searxng_settings, Windows, os.fchown, os.O_DIRECTORY, and SearXNG migration tests. No existing issue owns this platform-routing defect.
  • This is not a security vulnerability. It is a native Windows test-suite portability bug.
  • I verified the deterministic failure path on current dev at f7cbc885. A native Windows runner was not available; the unsupported CPython os attributes and unguarded test calls are source-complete.

Install Method

Windows native (launch-windows.ps1)

Operating System

Windows

Steps to Reproduce

  1. Check out current dev on native Windows with Python 3.11+ and the test dependencies installed.
  2. Run python -m pytest -q tests/test_searxng_settings_migration.py.
  3. Let any migration test reach the atomic write path, or reach test_temporary_file_is_chmodded_before_it_is_chowned.
  4. Observe access to Unix-only os.fchown; if that path is guarded, the directory fsync path also accesses Unix-only os.O_DIRECTORY.

Expected Behaviour

Native Windows contributors should not receive failures from a migration hook that runs only inside the Linux SearXNG container. The module should use the repository's established Windows skip convention, or the POSIX operations should be isolated behind an explicit platform abstraction with meaningful portable tests.

Actual Behaviour

The migration write path directly calls os.fchown and opens the parent with os.O_DIRECTORY, while tests/test_searxng_settings_migration.py has no Windows skip. CPython on Windows does not expose those Unix-only attributes, so the focused suite fails before it can test the intended Docker behavior.

Logs / Screenshots

AttributeError: module 'os' has no attribute 'fchown'

The POSIX calls are at scripts/migrate_searxng_settings.py:123. The test module imports and executes the migration without a platform guard at tests/test_searxng_settings_migration.py:1, including a direct migration.os.fchown lookup later in the suite. The repository already uses sys.platform == "win32" skips for POSIX-only assertions at tests/test_app_db_permissions.py:9.

Model / Backend (if relevant)

Not model-specific. Docker-only SearXNG settings migration test suite.

Are you willing to submit a fix?

Yes — I can open a focused PR.

Additional Information

Parent tracker: #6064.

The narrowest fix is a module-level or affected-test sys.platform == "win32" skip with a precise reason. If the implementation instead becomes portable, keep the Linux-container ownership and directory-fsync guarantees covered rather than weakening them for all platforms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingready for reviewDescription complete — ready for maintainer review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions