Skip to content

Missing vuforia_secrets.env produces 184 pydantic errors which never name the file #3403

Description

@adamtheturtle

What happens

vuforia_secrets.env is gitignored, so a fresh clone does not have one. docs/source/contributing.rst tells contributors to create it:

$ cp vuforia_secrets.env.example vuforia_secrets.env

If that step is missed, pytest does not report a missing file. Every test which touches a credentials fixture errors during setup with a raw pydantic validation error:

_ ERROR at setup of TestWidth.test_width_valid[In Memory version of Docker application] _

    @pytest.fixture
    def vuforia_database() -> CloudDatabase:
        """Return VWS credentials from environment variables."""
>       settings = _WorkingCloudDatabaseSettings.model_validate(obj={})
E       pydantic_core._pydantic_core.ValidationError: 6 validation errors for _WorkingCloudDatabaseSettings
E       server_access_key
E         Field required [type=missing, input_value={}, input_type=dict]
E           For further information visit https://errors.pydantic.dev/2.13/v/missing
E       server_secret_key
E         Field required [type=missing, input_value={}, input_type=dict]
...

That is six "Field required" entries per erroring test. In a run with --skip-real --skip-docker_build_tests it came to 184 errors. The string vuforia_secrets.env appears nowhere in the output, so nothing connects the failure to the file that needs creating — or to the line in the contributing guide that says to create it.

The settings classes point at the file with a relative path:

        env_file=Path("vuforia_secrets.env"),

so this also happens, identically, when pytest is run from anywhere other than the repository root even if the file does exist.

Why it matters

This is the default outcome for a new contributor who skips one line of setup, and it is a discouraging first impression: a wall of validation errors naming internal settings classes, from a test suite that otherwise runs cleanly in about four minutes.

CI never sees it, because both the ci-tests and skip-tests jobs copy a secrets file into place before running.

Low severity. Filing it because the fix is small and this is the one path where the project's otherwise careful contributor experience drops off.

How I found it

By accident, and worth stating plainly: I deleted vuforia_secrets.env while a background test run was still going, which produced the 184 errors. The suite itself is healthy — the same run with the file present gives 1082 passed, 491 skipped, no failures, no warnings.

Suggested resolution

A session-scoped pytest fixture, or a pytest_collection_modifyitems hook, which checks for the file once and fails with something like:

vuforia_secrets.env not found. Copy vuforia_secrets.env.example to
vuforia_secrets.env and fill it in. See the contributing documentation.

Resolving the env_file path relative to the repository root rather than the working directory would fix the run-from-a-subdirectory case at the same time. Path(__file__).parent.parent.parent.parent from credentials.py reaches the root, though a rootdir-based lookup through the pytest config would be less brittle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions