Skip to content

test_mobile_inspect_trace_invalid_action passes or fails based on unrelated on-disk state #62

Open

Description

@RohanOnKeys

Problem

tests/unit/mcp/test_mcp_tools.py::test_mobile_inspect_trace_invalid_action does not use the temp_trace_env fixture, so it calls mobile_inspect_trace against whatever trace_store.TRACES_DIR resolves to on the machine running the tests, which defaults to <project_root>/traces. mobile_inspect_trace checks for a data_engine.db file in that directory before it looks at the action argument at all. When the file is missing, the tool returns a "Database not found" error unconditionally, so the test's action="invalid_action" case never reaches the code path it is meant to check.

On a machine where <project_root>/traces/data_engine.db already exists, from an earlier local run, an earlier test in the same session, or a leftover dev artifact, the test passes by coincidence without ever exercising the "unsupported action" branch. On a clean checkout, or any environment where that file does not exist yet, the same test fails with an unrelated database error instead of the assertion it is written to check.

Root cause

In mcp_server/tools/inspect_trace.py, mobile_inspect_trace() resolves db_path from trace_store.TRACES_DIR (or a project_root/traces fallback) and returns early with a "Database not found" message if that path does not exist, before the action parameter is validated. The actual "Action '...' is not supported" branch only runs after that early return. The test never patches trace_store.TRACES_DIR and never seeds a database, so its result depends on incidental on disk state rather than the isolated condition it claims to test.

Safe reproduction

Run the test by itself on a checkout with no traces/data_engine.db under the project root:

pytest tests/unit/mcp/test_mcp_tools.py::test_mobile_inspect_trace_invalid_action

Result:

AssertionError: assert 'not supported' in 'Data engine database does not exist at <project_root>/traces/data_engine.db yet.'

Creating any file, empty or not, at that path makes the test pass, since the only gate before the final else branch is os.path.exists(db_path). The action never touches the database contents for an unknown action string, so the test's real intent (validating unknown-action handling) is never actually exercised either way.

Possible fix direction

Give this test its own isolated trace environment, the same way the other tests in this module do, for example by requesting temp_trace_env and writing an empty data_engine.db into it before calling mobile_inspect_trace. That would make the pass or fail result depend only on the action-validation logic, not on whatever is left on disk.

Activity

  1. added 3 commits that reference this issue on Sep 13, 2026
  2. RohanOnKeys commented on Sep 14, 2026

    @RohanOnKeys
    Author

    #66 is already filed to fix this. i would love if the community stops spamming same soluion pr @rollroyces @basil-k-aji-dev
    please close #87 and #81.
    also if you have something to add , please write edits on #66, but do not raise another spam ai sloppish pr

  3. RohanOnKeys commented on Sep 14, 2026

    @RohanOnKeys
    Author

    you are essentially taking up credits on my work, without checking if there is an earlier pr or not. also the filed or #81 and #87 are essentially ai generated and not upto the standards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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