Repository navigation
Description
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 intmp_path, not intmp_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_DIRa folder that platformdirs 4.14.8 accepts, or make_runtime_folderhandle the new check, whichever keeps the token folder private.
Proof
Service Image Tests (shard 6 of 6)passes on a pull request that changesuv.lockorDockerfile.
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 -qruns withTMPDIRbelow 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_DIRis 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_pathreturns a path that is a regular file - THEN
_runtime_folderreturns a private folder under the temp folder andtest_a_gh_child_whose_runtime_folder_fails_gets_a_new_folder_of_the_temp_folderpasses.
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 changesuv.lockorDockerfile - 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_DIRbelow a parent that another user can replace. The Service image temp parent is such a parent, so_runtime_folderuses 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_pathin the two tests to return a private folder undertmp_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_DIRbelowtmp_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.
- Rejected: Set
- 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_DIRdirectly. 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
dan-petty commentedon Nov 20, 2026
core, and .github/labels.yml declares no scope/core label. Add the label to the file to give the scope to this item.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.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.devops-cli-service commentedon Nov 20, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
docs(openspec): plan and archive #6533 Give the runtime folder direct…
dan-petty commentedon Nov 20, 2026
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_folderandtest_the_root_of_the_file_system_as_the_current_folder_skips_no_candidateintests/core/test_process.py. #6536 does not changesrc/devops_cli/core/process.pyor these tests.dan-petty commentedon Nov 20, 2026
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.pyor platformdirs, so the cause stays this item.