Skip to content

fix(telemetry): building the tracer starts uname -p through platform.platform(), so tests fail when they run first in their process #1418

Closed

Description

@dan-petty

Problem

Tracer.__init__ sets the os.description resource attribute from platform.platform() (src/devops_cli/telemetry/tracer.py:742 on release/v0.2.29 at 05e9388). On Linux that reads platform.uname().processor, which runs uname -p through subprocess the first time a process asks. The tracer is built on first use, from trace_span (for example core/cli.py:97, _execute_traced_cli_command, and the span run_subprocess opens). So the first traced call in each process starts a uname child, dry runs included.

In tests, a fake that replaces subprocess.run receives that argv, and the result depends on test order:

They pass in the full suite only because an earlier test in the same xdist worker filled platform's cache. The covering-test pre-commit hook runs a small selection, so it can fail on a change that doesn't touch these tests.

Proposed remedy

Build os.description from values that start no process, such as os.uname() (sysname, release, version) or platform.system()/platform.release()/platform.version(), which don't read the processor. No traced command then starts uname, whatever the test order.

Acceptance criteria

  • A test builds the tracer with subprocess.run and subprocess.Popen replaced by fakes that fail on any call, and asserts that os.description is set and no process started.
  • Both tests named above pass when run alone (uv run pytest <nodeid> -n0 -p no:randomly).
  • Tests are offline, each call phase stays under 1 s, and uv run devops ci passes.

Found while delivering #1358 and #1364. Related: #1358, #1364.

Update 2026-10-08: merged from #1411

#1411 is closed as a duplicate.

  • uv run pytest tests/test_github_rate_limiter.py -n0 passes in file order and one shuffled order (pytest-randomly is not a dependency), each call phase under 1 s.

Activity

  1. added
    type/bug
    scope/telemetry
    scope/ci
    source/agent
    on Oct 8, 2026
  2. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Priority: P2-Medium. It causes intermittent test and pre-commit hook failures but does not affect production behavior.
    • Value: Medium. It makes the test suite order-dependent and can trigger spurious CI or pre-commit failures, hurting developer productivity.
    • Effort: Low. The fix replaces one function call with an equivalent that does not spawn a subprocess, plus a small verification test.
  3. dan-petty commented on Oct 20, 2026

    @dan-petty
    OwnerAuthor

    This is already delivered.

    • src/devops_cli/telemetry/tracer.py reads platform.system() and platform.release().
    • The regression test is in tests/test_telemetry.py. It landed in v0.2.33 (69c99cf).
    • Both named tests pass alone with -n 0, checked on 2026-10-20 at the v0.2.37 tip.

    Closing as completed. The platform.processor() pre-warm in tests/test_ci_dry_run.py can now go in any change that touches that file.

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

    scope/ciscope/telemetrysource/agenttype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions