Core: ignore empty LOCALAPPDATA, XDG_CACHE_HOME, and HOME in default directory resolution #2579

Open
github-bot wants to merge 1 commit from github-bot/gh-2579 into main AGit
Owner

@⁠reeledMarek on GitHub · 2026-11-25 16:08 UTC · original
reeledMarek:fix/core-config-default-dir-empty-env → main · +34 −4 · 1 files · 1 commits · open

Summary

In victory-core/src/config.rs, empty environment variables (LOCALAPPDATA="", XDG_CACHE_HOME="", HOME="") were treated as valid base paths, causing default cache/config directories to resolve to relative paths under the current working directory instead of falling back properly.

Now empty values are ignored during default directory resolution.

Testing

  • cargo test -p victory-core --locked (14/14 passed, including synthetic tests for empty env values)
  • cargo clippy -p victory-core --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings (clean)
  • cargo test -p xtask --locked (6/6 passed)
**@⁠reeledMarek** on GitHub · 2026-11-25 16:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2579) `reeledMarek:fix/core-config-default-dir-empty-env` → `main` · +34 −4 · 1 files · 1 commits · open ### Summary In `victory-core/src/config.rs`, empty environment variables (`LOCALAPPDATA=""`, `XDG_CACHE_HOME=""`, `HOME=""`) were treated as valid base paths, causing default cache/config directories to resolve to relative paths under the current working directory instead of falling back properly. Now empty values are ignored during default directory resolution. ### Testing - `cargo test -p victory-core --locked` (14/14 passed, including synthetic tests for empty env values) - `cargo clippy -p victory-core --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings` (clean) - `cargo test -p xtask --locked` (6/6 passed)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:09:41 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:18 UTC · original

Automated triage for the maintainers.

Merge candidate (small). In victory-core/src/config.rs, default_dir took an empty LOCALAPPDATA, XDG_CACHE_HOME or HOME as a base. That gave a relative victory/<name> under the current folder. Now empty values fall through to the next variable, and then to the existing "set VICTORY_CACHE_DIR and VICTORY_DATA_DIR" error. This matches how the same file already treats empty VICTORY_GAME_DIR/VICTORY_CONFIG (see its existing tests). The default_dir_from split with an injected env follows the file's pattern, and the test covers both the fallback and the error.

CI: check passing. Merges cleanly into current main. A recommendation to look at it, not an approval.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2579#issuecomment-7176198889) <!-- victory-triage v1 head=61349a7fcf3d651aa812cf8b8c7369f68f7011ed verdict=merge-candidate at=2026-11-25T22:18:19Z --> Automated triage for the maintainers. **Merge candidate (small).** In `victory-core/src/config.rs`, `default_dir` took an empty `LOCALAPPDATA`, `XDG_CACHE_HOME` or `HOME` as a base. That gave a relative `victory/<name>` under the current folder. Now empty values fall through to the next variable, and then to the existing "set VICTORY_CACHE_DIR and VICTORY_DATA_DIR" error. This matches how the same file already treats empty `VICTORY_GAME_DIR`/`VICTORY_CONFIG` (see its existing tests). The `default_dir_from` split with an injected `env` follows the file's pattern, and the test covers both the fallback and the error. CI: `check` passing. Merges cleanly into current `main`. A recommendation to look at it, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠lcg007xd-c on GitHub · 2026-11-25 21:21 UTC · original · approved these changes

Verified on Linux (Rust 1.99.0)

Branch: current main (13f91ca) + this PR (merges cleanly; it also merges cleanly with #2578).

  • cargo test --locked -p victory-core: 14 passed.
  • With the .filter(|v| !v.is_empty()) in default_dir_from removed (refactor kept), default_dir_ignores_empty_user_env_vars fails. So the test pins the fix.
  • cargo clippy --locked --target x86_64-pc-windows-msvc -p victory-core --all-targets -- -D warnings: clean, same as main.

Review

The fix is correct, and it makes default_dir consistent with resolve's own env_path, which already drops empty values (config.rs:85). No defect found.

Prior art: the same fix was in #243 ("Config: skip an empty or relative cache base for the default directories"), which was folded into #241. #241 was then closed unmerged yesterday after a needs-rebase triage. So nothing on main covers this, and this PR is the live version. Two small follow-ups, either here or later:

  1. Relative values. #243 also skipped relative bases. The XDG Base Directory spec says implementations should treat a relative path in these variables as invalid and ignore it. XDG_CACHE_HOME=foo still yields foo/victory/cache under the working directory here, which is usually the checkout, and subdir then fails with the asset-policy error. Adding .filter(|p| p.is_absolute()) to get would cover it.
  2. Hermetic resolve. Config::resolve takes an injectable env, but its fallback still calls default_dir, which reads the real process environment (config.rs:93-97). Passing resolve's env through to default_dir_from would make the existing resolve tests independent of the host's LOCALAPPDATA/HOME.

Not verified

  • Windows runtime behaviour with an empty LOCALAPPDATA. Only the logic is covered, through the injected env.

Reviewed with Claude Code.

**@⁠lcg007xd-c** on GitHub · 2026-11-25 21:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2579#pullrequestreview-6065155886) · **approved these changes** ### Verified on Linux (Rust 1.99.0) Branch: current `main` (13f91ca) + this PR (merges cleanly; it also merges cleanly with #2578). - `cargo test --locked -p victory-core`: 14 passed. - With the `.filter(|v| !v.is_empty())` in `default_dir_from` removed (refactor kept), `default_dir_ignores_empty_user_env_vars` fails. So the test pins the fix. - `cargo clippy --locked --target x86_64-pc-windows-msvc -p victory-core --all-targets -- -D warnings`: clean, same as main. ### Review The fix is correct, and it makes `default_dir` consistent with `resolve`'s own `env_path`, which already drops empty values (config.rs:85). No defect found. Prior art: the same fix was in #243 ("Config: skip an empty or relative cache base for the default directories"), which was folded into #241. #241 was then closed unmerged yesterday after a needs-rebase triage. So nothing on main covers this, and this PR is the live version. Two small follow-ups, either here or later: 1. **Relative values.** #243 also skipped relative bases. The XDG Base Directory spec says implementations should treat a relative path in these variables as invalid and ignore it. `XDG_CACHE_HOME=foo` still yields `foo/victory/cache` under the working directory here, which is usually the checkout, and `subdir` then fails with the asset-policy error. Adding `.filter(|p| p.is_absolute())` to `get` would cover it. 2. **Hermetic `resolve`.** `Config::resolve` takes an injectable `env`, but its fallback still calls `default_dir`, which reads the real process environment (config.rs:93-97). Passing `resolve`'s `env` through to `default_dir_from` would make the existing `resolve` tests independent of the host's `LOCALAPPDATA`/`HOME`. ### Not verified - Windows runtime behaviour with an empty `LOCALAPPDATA`. Only the logic is covered, through the injected env. Reviewed with Claude Code.
Author
Owner

@⁠Will-0f-D on GitHub · 2026-11-26 16:14 UTC · original

Independent native Windows verification of this PR at
61349a7fcf3d651aa812cf8b8c7369f68f7011ed, with main
63bcca43c6a00a758510398fa43096ce7e4f7df0 as the negative control.

Environment: Windows 11 Pro x64 (10.0.26300), Rust 1.98.1,
x86_64-pc-windows-msvc.

I built the same standalone probe against each checkout. Each case invokes
the public Config::load() API in a separate child process, removing the
relevant environment variables first and using a working directory with no
victory.toml. This tests the real environment path rather than calling
the injected helper directly. Both cache_dir and data_dir are checked.

Check Main PR head
Independent 10-case environment matrix 5 pass, 5 fail 10 pass
cargo test -p victory-core --locked 13 pass 14 pass
cargo clippy -p victory-core --all-targets --locked -- -D warnings not run clean
cargo test -p xtask --locked not run 6 pass

The five negative-control failures are:

  • All three base variables empty should produce the existing missing-base error.
  • Empty LOCALAPPDATA should fall through to a valid XDG_CACHE_HOME.
  • Empty LOCALAPPDATA and XDG_CACHE_HOME should fall through to a valid HOME.
  • Absent LOCALAPPDATA and empty XDG_CACHE_HOME should fall through to HOME.
  • Empty HOME with the other bases absent should produce the missing-base error.

Main returns relative paths for these cases; this PR produces the expected
fallbacks or error. The passing controls cover all bases absent, normal
LOCALAPPDATA/XDG/HOME precedence, HOME's .cache component, and explicit
VICTORY_CACHE_DIR/VICTORY_DATA_DIR overrides when the bases are empty.

No game files, GPU or gameplay used. No production code changes or duplicate
fix: credit for the implementation remains with the PR author.

AI-assisted verification and probe authoring with OpenAI Codex. This is a
focused verification report, not a full-workspace test or formal approval.

**@⁠Will-0f-D** on GitHub · 2026-11-26 16:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/2579#issuecomment-7197379273) Independent native Windows verification of this PR at `61349a7fcf3d651aa812cf8b8c7369f68f7011ed`, with main `63bcca43c6a00a758510398fa43096ce7e4f7df0` as the negative control. Environment: Windows 11 Pro x64 (`10.0.26300`), Rust `1.98.1`, `x86_64-pc-windows-msvc`. I built the same standalone probe against each checkout. Each case invokes the public `Config::load()` API in a separate child process, removing the relevant environment variables first and using a working directory with no `victory.toml`. This tests the real environment path rather than calling the injected helper directly. Both `cache_dir` and `data_dir` are checked. | Check | Main | PR head | |---|---:|---:| | Independent 10-case environment matrix | 5 pass, 5 fail | 10 pass | | `cargo test -p victory-core --locked` | 13 pass | 14 pass | | `cargo clippy -p victory-core --all-targets --locked -- -D warnings` | not run | clean | | `cargo test -p xtask --locked` | not run | 6 pass | The five negative-control failures are: - All three base variables empty should produce the existing missing-base error. - Empty LOCALAPPDATA should fall through to a valid XDG_CACHE_HOME. - Empty LOCALAPPDATA and XDG_CACHE_HOME should fall through to a valid HOME. - Absent LOCALAPPDATA and empty XDG_CACHE_HOME should fall through to HOME. - Empty HOME with the other bases absent should produce the missing-base error. Main returns relative paths for these cases; this PR produces the expected fallbacks or error. The passing controls cover all bases absent, normal LOCALAPPDATA/XDG/HOME precedence, HOME's `.cache` component, and explicit VICTORY_CACHE_DIR/VICTORY_DATA_DIR overrides when the bases are empty. No game files, GPU or gameplay used. No production code changes or duplicate fix: credit for the implementation remains with the PR author. AI-assisted verification and probe authoring with OpenAI Codex. This is a focused verification report, not a full-workspace test or formal approval.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 17:39 UTC · original · approved these changes

Looks good. Verified merged onto main (63bcca43) on Windows 11:

  • default_dir_from (crates/victory-core/src/config.rs:147-159) cleanly filters empty values via .filter(|v| !v.is_empty()), matching the existing env_path and explicit_config_path conventions in config.rs and preserving non-UTF-8 OsString paths.
  • cargo xtask policy (191 files ok), cargo clippy --locked -p victory-core --all-targets -- -D warnings (default and --all-features), and cargo test --locked -p victory-core (14/14, including default_dir_ignores_empty_user_env_vars) all pass.
  • Additional verification passed across the full 27-state (LOCALAPPDATA, XDG_CACHE_HOME, HOME) x {unset, "", valid} matrix, a Windows unpaired-surrogate OsString path check, and 3 real Windows 11 child-process Config::load() checks confirming empty LOCALAPPDATA falls through to XDG_CACHE_HOME, then HOME/.cache, and returns Err when all three are empty.

(Non-blocking note: Config::resolve still calls default_dir directly rather than threading its env closure into default_dir_from, which is fine as-is and can be left for a separate cleanup if ever needed.)

**@⁠fuzeofficlal** on GitHub · 2026-11-26 17:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2579#pullrequestreview-6078507560) · **approved these changes** Looks good. Verified merged onto `main` (`63bcca43`) on Windows 11: - `default_dir_from` (`crates/victory-core/src/config.rs:147-159`) cleanly filters empty values via `.filter(|v| !v.is_empty())`, matching the existing `env_path` and `explicit_config_path` conventions in `config.rs` and preserving non-UTF-8 `OsString` paths. - `cargo xtask policy` (`191 files ok`), `cargo clippy --locked -p victory-core --all-targets -- -D warnings` (default and `--all-features`), and `cargo test --locked -p victory-core` (14/14, including `default_dir_ignores_empty_user_env_vars`) all pass. - Additional verification passed across the full 27-state `(LOCALAPPDATA, XDG_CACHE_HOME, HOME)` x `{unset, "", valid}` matrix, a Windows unpaired-surrogate `OsString` path check, and 3 real Windows 11 child-process `Config::load()` checks confirming empty `LOCALAPPDATA` falls through to `XDG_CACHE_HOME`, then `HOME/.cache`, and returns `Err` when all three are empty. (Non-blocking note: `Config::resolve` still calls `default_dir` directly rather than threading its `env` closure into `default_dir_from`, which is fine as-is and can be left for a separate cleanup if ever needed.)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2579/head:github-bot/gh-2579'
git switch 'github-bot/gh-2579'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2579'
git switch 'github-bot/gh-2579'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2579'
git switch 'github-bot/gh-2579'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2579'
git switch 'main'
git merge --squash 'github-bot/gh-2579'
git switch 'main'
git merge --ff-only 'github-bot/gh-2579'
git switch 'main'
git merge 'github-bot/gh-2579'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2579
No description provided.