Skip to content

fix(core): token folder tests fail in the Service image #6533

Closed

Description

@dan-petty

Problem

Two tests of tests/core/test_process.py fail in the Service Image Tests (shard 6 of 6) since #6506 moved platformdirs from 4.14.7 to 4.14.8:

  • test_a_link_below_the_runtime_folder_does_not_move_the_token_folder: the token folder is in tmp_path, not in tmp_path/runtime.
  • test_the_root_of_the_file_system_as_the_current_folder_skips_no_candidate: the folder is not the expected path.

Runs: 44765767133 (#6506, job 136391506076) and 44769864838 (#6530, job 136406790475). The last run before #6506 (44763835263) passed. The other jobs of ci.yml pass, because they run the suite on the runner and not in the Service image.

Probable cause, not confirmed: user_runtime_dir of platformdirs 4.14.8 accepts $XDG_RUNTIME_DIR "only below parents no other user can replace" (platformdirs/unix.py), and else falls back. The tests set XDG_RUNTIME_DIR to a folder below tmp_path. In the Service image, platformdirs can refuse a parent of that folder, and then _runtime_folder in src/devops_cli/core/process.py gets the fallback.

Change

  • Confirm the cause in the Service image with platformdirs 4.14.8.
  • Make the two tests give XDG_RUNTIME_DIR a folder that platformdirs 4.14.8 accepts, or make _runtime_folder handle the new check, whichever keeps the token folder private.

Proof

  • Service Image Tests (shard 6 of 6) passes on a pull request that changes uv.lock or Dockerfile.

Source

Source: #6530

Proposed design

Problem statement

Two tests in tests/core/test_process.py fail in the Service Image Tests (shard 6 of 6) after platformdirs 4.14.8 tightened its XDG_RUNTIME_DIR acceptance. The tests must not depend on the Service image temp parent, and the token folder must stay private.

Acceptance criteria

Requirement: Runtime path is isolated in the two tests

The two token-folder tests SHALL set the runtime folder through a monkeypatched platformdirs.user_runtime_path, not through XDG_RUNTIME_DIR.

Scenario: Run under a replaceable temp parent

  • WHEN uv run pytest tests/core/test_process.py -q runs with TMPDIR below a world-writable parent
  • THEN the test process exits 0 and both named tests pass.

Requirement: Token folder stays private

The token folder SHALL be a new directory with mode 0700 below the runtime folder and SHALL NOT follow a symbolic link below that folder.

Scenario: A link below the runtime folder

  • WHEN the test creates a symbolic link below the monkeypatched runtime folder and runs a gh child
  • THEN GH_CONFIG_DIR is a new directory with mode 0700 below the runtime folder, and its path is not the link target.

Requirement: Fallback stays private

_runtime_folder MUST keep the platformdirs fallback when the configured runtime folder cannot hold a folder.

Scenario: Runtime folder fails

  • WHEN platformdirs.user_runtime_path returns a path that is a regular file
  • THEN _runtime_folder returns a private folder under the temp folder and test_a_gh_child_whose_runtime_folder_fails_gets_a_new_folder_of_the_temp_folder passes.

Requirement: Service image shard 6 passes

Service Image Tests (shard 6 of 6) MUST pass on a pull request that changes uv.lock or Dockerfile.

Scenario: Service image workflow

  • WHEN the Service Image Tests (shard 6 of 6) job runs on a pull request that changes uv.lock or Dockerfile
  • THEN the job completes successfully.

Existing Tool Considered

No alternatives check has run. The open, maintained platformdirs library at 4.14.8 supplies the runtime folder; no new tool or library is needed. It lacks an API to accept an XDG_RUNTIME_DIR below a replaceable parent, so the two tests monkeypatch its runtime path and the production fallback stays unchanged.

Key questions

  • What causes the two tests to fail in the Service image?: The issue reports that platformdirs 4.14.8 refuses XDG_RUNTIME_DIR below a parent that another user can replace. The Service image temp parent is such a parent, so _runtime_folder uses its fallback and the tests see the wrong folder. Refine must confirm this in the Service image before the test change. [sources: tests/core/test_process.py:825, tests/core/test_process.py:878, src/devops_cli/core/process.py:505]
  • How should the two tests supply the runtime folder?: Monkeypatch platformdirs.user_runtime_path in the two tests to return a private folder under tmp_path. (best practice) [sources: tests/core/test_process.py:825, tests/core/test_process.py:878, src/devops_cli/core/process.py:505, tests/core/test_process.py]
    • Rejected: Set XDG_RUNTIME_DIR below tmp_path. The Service image temp parent is replaceable by other users, so platformdirs 4.14.8 refuses it.
    • Chosen: Monkeypatch platformdirs.user_runtime_path. It isolates the token-folder tests from host temp permissions and keeps the production fallback unchanged.
    • Rejected: Add a new safety check to _runtime_folder. It duplicates platformdirs' security check and can make the token folder less private.
  • Should production code change to handle the new platformdirs check?: Keep the existing platformdirs fallback in _runtime_folder; change only the two tests. (best practice) [sources: src/devops_cli/core/process.py:505, tests/core/test_process.py]
    • Chosen: Keep the platformdirs fallback. The existing fallback already creates a private temp folder and has a test.
    • Rejected: Bypass platformdirs and read XDG_RUNTIME_DIR directly. It would skip the new security check and can accept a replaceable folder.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    on Nov 20, 2026
  2. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor
    • Scope: none. The title has the scope core, and .github/labels.yml declares no scope/core label. Add the label to the file to give the scope to this item.
    • Priority: P1-High. Two tests fail in the Service Image Tests shard, causing CI to fail. The failed run 44765767133 does not set P0: the author has no write access, and no caller attached it as evidence. A person can set P0 with the label priority/p0-critical.
    • Related: fix(tests): the plain-Python helper test fails in the Service image #4891, which asks for a different change. Both fix a test that fails only in the Service image, but #4891 fixes a pytest import in a child process while this fixes XDG_RUNTIME_DIR handling for platformdirs 4.14.8.
  3. added
    source/agent
    status/new
    value/medium
    effort/low
    priority/p1-high
    on Nov 20, 2026
  4. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  5. added
    owner/agent
    on Nov 20, 2026
  6. added a commit that references this issue on Nov 20, 2026
  7. added
    status/in-progress
    and removed
    status/new
    on Nov 20, 2026
  8. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    The same two tests fail in Service Image Tests (shard 6 of 6) of #6536 (job 136431182621 of run 44777105649): test_a_link_below_the_runtime_folder_does_not_move_the_token_folder and test_the_root_of_the_file_system_as_the_current_folder_skips_no_candidate in tests/core/test_process.py. #6536 does not change src/devops_cli/core/process.py or these tests.

  9. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    PR #6537 (the runner image without the dev group, #6517) fails the same two tests in Service Image Tests (shard 6 of 6), run 44777917858, job 136433645919. The pull request does not change src/devops_cli/core/process.py or platformdirs, so the cause stays this item.

  10. added
    status/in-review
    and removed
    status/in-progress
    on Nov 20, 2026
  11. removed
    status/in-review
    owner/agent
    on Nov 20, 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

    effort/lowpriority/p1-highsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions