Skip to content

fix(server): devops serve --service leaves the process's logging alone until uvicorn applies its json config, so in-process tests keep their captured logs #1543

Closed

Description

@dan-petty

Found while fixing the checks of release pull request #1537 (owner, 2026-10-10: "fix release branch").

Problem

Checked at release/v0.2.33 (5c5df79).

  • Before calling uvicorn.run, devops serve --service sets up the process's logging itself, through setup_service_logging (src/devops_cli/server/json_logs.py). That call clears the root logger's handlers, installs a JSON stdout handler, and gives the devops_cli logger its own handler with propagate=False.
  • Tests run the command in the pytest process with only uvicorn.run doubled, for example tests/test_roadmap_run.py::test_service_wiring, which fix(roadmap): the service runs close and reprioritize in their own lane, so a slow model-bound intake or refine round never holds up a release #1532 changed in this release. The logging setup then stays for the rest of the session. A later test's caplog sees no devops_cli records.
  • On feat(release): v0.2.33 #1537, the Changed-Test Independence check failed run 2 of 3 (seed 281456038). tests/test_fastmcp_contracts.py::test_a_handler_failure_reports_its_exception_type and ::test_the_dispatch_record_still_reports_its_duration ran after that test and found an empty log.

Proposed design

  • setup_service_logging becomes service_log_config(log_level), a standard logging.config.dictConfig dict with disable_existing_loggers: False. serve --service passes it to uvicorn as log_config.
  • uvicorn builds the app through a factory (factory=True), as the --reload path already does, so the startup warning for a repository without a webhook secret is still logged as JSON.

Acceptance criteria

  • After serve --service runs in-process with uvicorn doubled, a devops_cli record still reaches caplog (tests/test_server.py).
  • No missing-secret warning is logged before uvicorn.run is called, and exactly one is logged once the factory builds the app (tests/test_server.py).
  • The seeded run that failed on feat(release): v0.2.33 #1537 passes three times, and two other seeds pass.
  • changelog.d/<issue>.md under ### Fixed.

Feasibility

Fits one pull request: one function in src/devops_cli/server/json_logs.py, the call in src/devops_cli/commands/serve.py, and their tests.

Activity

  1. added this to the v0.2.33 milestone on Oct 10, 2026
  2. added
    type/bug
    scope/cli
    scope/telemetry
    on Oct 10, 2026
  3. dan-petty-bot commented on Oct 10, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item kept in v0.2.33: a person placed it in v0.2.33, and that placement stands.

    • Priority: P2-Medium. It causes seed-dependent CI failures (Changed-Test Independence) but does not affect production behaviour.
    • Value: Medium. Restores reliable test isolation for the server test suite without changing user-facing behaviour.
    • Effort: Low. The body scopes it to one function, one call site, and their tests in a single pull request.
  4. dan-petty-bot commented on Oct 10, 2026

    @dan-petty-bot
    Collaborator

    Admitted to v0.2.33: an open or merged pull request is in flight for it. (devops roadmap reprioritize)

  5. dan-petty-bot commented on Oct 10, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1545, merged into release/v0.2.33 as 8fe21cc.

    Summary

    • devops serve --service set up the process's JSON logging itself before calling uvicorn.run: it cleared the root logger's handlers and gave devops_cli its own handler with propagate=False. Tests that run the command in process with uvicorn doubled (tests/test_roadmap_run.py::test_service_wiring, changed by fix(roadmap): the service runs close and reprioritize in their own lane, so a slow model-bound intake or refine round never holds up a release #1532) left that state behind, so later tests' caplog saw no devops_cli records. That failed release PR feat(release): v0.2.33 #1537's Changed-Test Independence check (seed 281456038): the two dispatcher log tests in tests/test_fastmcp_contracts.py.
    • setup_service_logging becomes service_log_config(log_level), a dictConfig dict that serve --service hands to uvicorn as log_config. uvicorn builds the app through a factory (factory=True, as --reload does), after applying the config, so the startup warning for a repository without a webhook secret stays a JSON line.
    • Task file docs/agent/tasks/task-1543-serve-service-logging-left-to-uvicorn.md; changelog.d/1543.md under ### Fixed.

    Closes #1543

    6 file(s) changed.

    How it was verified

    Check runs at 8b48a73:

    • Prune PR DevContainer Images: pass
    • bandit: pass
    • devops-cli: pass
    • CodeQL: pass
    • DevContainer Image: skipping
    • Static Analysis: fail
    • Analyze (actions): pass
    • Analyze (python): pass
    • Tests & Coverage: pending
    • Changed-Test Independence: fail
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1543-serve-service-logging-left-to-uvicorn.md:

    • After serve --service runs in process with uvicorn doubled, a devops_cli log record still reaches caplog (tests/test_server.py); it failed before the fix.
    • No missing-secret warning is logged before uvicorn.run is called, and exactly one is logged once the factory builds the app (tests/test_server.py::test_serve_service_mode_builds_the_app_after_the_server_applies_its_logging); it failed against the first version of the fix.
    • tests/test_roadmap_run.py::test_service_wiring reads the app from the factory uvicorn receives.
    • The seeded run that failed on feat(release): v0.2.33 #1537 (uv run pytest -n 0 -p randomly --randomly-seed=281456038 over the changed test files) passes, and so do two other seeds.
    • changelog.d/1543.md holds the entry under ### Fixed.
    • uv run devops ci is the pull request's gate.
    • Pending a person, once v0.2.33 deploys: kubectl -n devops logs deploy/roadmap-service -c service --since=10m shows single-line JSON records from devops_cli and uvicorn, each once.
  6. added a commit that references this issue on Oct 10, 2026
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/cliscope/telemetrytype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions