Config: ignore an empty VICTORY_CONFIG #363

Merged
enzoduarte1 merged 1 commit from upstream-pr/363 into main 2026-11-25 00:19:50 +00:00
enzoduarte1 commented 2026-11-24 02:36:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by enzoduarte1 on 2026-11-24T02:36:53Z.


What

Config::load treats an empty VICTORY_CONFIG as an explicit path: PathBuf::from("") is not a file, so startup fails with VICTORY_CONFIG points at , which does not exist. The other path variables in resolve ignore empty values; PR #341 makes VICTORY_TEST_TITLES consistent with them.

The environment lookup now goes through a small helper that filters empty values, so VICTORY_CONFIG= falls back to ./victory.toml (or no config file) instead of aborting. A non-empty value still selects that exact file. A unit test covers empty and non-empty values.

Tested

  • Windows 11, Rust 1.98.1, x86_64-pc-windows-gnu (this machine has no MSVC linker).
  • cargo test -p victory-core: 9 passed, 0 failed.
  • cargo test --workspace --exclude victory-loader: all suites passed.
  • cargo clippy -p victory-core --all-targets -- -D warnings: clean.
  • cargo clippy --workspace --all-targets: finishes successfully; it still reports the pre-existing warnings that PR #355 fixes.
  • rustfmt --edition 2024 --check crates/victory-core/src/config.rs and git diff --check: clean.
  • cargo xtask policy: 151 files ok. No game files or data taken from them were added.
  • Not tested: cargo test -p victory-loader --test load_probe. Its fixture passes MSVC's /DELAYLOAD link flag, which MinGW's linker rejects here; the same failure occurs on unmodified main. cargo fmt --all --check also has unrelated pre-existing diffs, so no other files were reformatted.

Checklist

  • cargo fmt, cargo clippy --workspace --all-targets and cargo test --workspace pass — see the toolchain limitations above; the changed crate is clean.
  • cargo xtask policy passes. The change adds no game files or data taken from them (docs/asset-policy.md).
  • If an AI tool wrote part of this change, the description says so: an AI tool assisted with the code and test; I reviewed and ran them.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6573352785 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/363). Originally posted by [enzoduarte1](https://github.com/enzoduarte1) on 2026-11-24T02:36:53Z. --- ## What `Config::load` treats an empty `VICTORY_CONFIG` as an explicit path: `PathBuf::from("")` is not a file, so startup fails with `VICTORY_CONFIG points at , which does not exist`. The other path variables in `resolve` ignore empty values; PR #341 makes `VICTORY_TEST_TITLES` consistent with them. The environment lookup now goes through a small helper that filters empty values, so `VICTORY_CONFIG=` falls back to `./victory.toml` (or no config file) instead of aborting. A non-empty value still selects that exact file. A unit test covers empty and non-empty values. ## Tested - Windows 11, Rust 1.98.1, `x86_64-pc-windows-gnu` (this machine has no MSVC linker). - `cargo test -p victory-core`: 9 passed, 0 failed. - `cargo test --workspace --exclude victory-loader`: all suites passed. - `cargo clippy -p victory-core --all-targets -- -D warnings`: clean. - `cargo clippy --workspace --all-targets`: finishes successfully; it still reports the pre-existing warnings that PR #355 fixes. - `rustfmt --edition 2024 --check crates/victory-core/src/config.rs` and `git diff --check`: clean. - `cargo xtask policy`: 151 files ok. No game files or data taken from them were added. - Not tested: `cargo test -p victory-loader --test load_probe`. Its fixture passes MSVC's `/DELAYLOAD` link flag, which MinGW's linker rejects here; the same failure occurs on unmodified `main`. `cargo fmt --all --check` also has unrelated pre-existing diffs, so no other files were reformatted. ## Checklist - [ ] `cargo fmt`, `cargo clippy --workspace --all-targets` and `cargo test --workspace` pass — see the toolchain limitations above; the changed crate is clean. - [x] `cargo xtask policy` passes. The change adds no game files or data taken from them (`docs/asset-policy.md`). - [x] If an AI tool wrote part of this change, the description says so: an AI tool assisted with the code and test; I reviewed and ran them.
SkippySteve commented 2026-11-24 06:55:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by SkippySteve on 2026-11-24T03:06:45Z.


Thanks for this. The bug is real: on main, VICTORY_CONFIG= is turned into PathBuf::from(""), and startup stops with VICTORY_CONFIG points at , which does not exist. The fix is right too.

What I checked

  • On the PR head (4874c3f), Linux, cargo test -p victory-core config: 5 passed, including the new empty_config_env_is_ignored.
  • The new helper takes an env closure, the same way resolve does, so the test doesn't change the process environment. Good.

This overlaps with #241
#241 (Core host UX: XDG data dir, config-relative paths) already has this fix. Its explicit_config does the same .filter(|v| !v.is_empty()) on VICTORY_CONFIG, and the module docs now say "a variable that is set but empty counts as unset". Its test victory_config_expands_tilde_and_ignores_empty covers the empty value. It also expands a leading ~ and gives a clearer error when the value names a folder.

The two PRs change the same lines of Config::load, so merging one gives the other a conflict in crates/victory-core/src/config.rs. I checked this with a trial merge.

Suggestion

  • If #241 lands first, this PR isn't needed any more and can be closed.
  • If maintainers would like this small fix in sooner, it's fine to merge on its own. #241 will then rebase onto it and drop its copy of the filter.

Either way, nothing needs to change in this PR.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7120781686 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/363#issuecomment-7120781686). Originally posted by [SkippySteve](https://github.com/SkippySteve) on 2026-11-24T03:06:45Z. --- Thanks for this. The bug is real: on `main`, `VICTORY_CONFIG=` is turned into `PathBuf::from("")`, and startup stops with `VICTORY_CONFIG points at , which does not exist`. The fix is right too. **What I checked** - On the PR head (`4874c3f`), Linux, `cargo test -p victory-core config`: 5 passed, including the new `empty_config_env_is_ignored`. - The new helper takes an env closure, the same way `resolve` does, so the test doesn't change the process environment. Good. **This overlaps with #241** #241 (Core host UX: XDG data dir, config-relative paths) already has this fix. Its `explicit_config` does the same `.filter(|v| !v.is_empty())` on `VICTORY_CONFIG`, and the module docs now say "a variable that is set but empty counts as unset". Its test `victory_config_expands_tilde_and_ignores_empty` covers the empty value. It also expands a leading `~` and gives a clearer error when the value names a folder. The two PRs change the same lines of `Config::load`, so merging one gives the other a conflict in `crates/victory-core/src/config.rs`. I checked this with a trial merge. **Suggestion** - If #241 lands first, this PR isn't needed any more and can be closed. - If maintainers would like this small fix in sooner, it's fine to merge on its own. #241 will then rebase onto it and drop its copy of the filter. Either way, nothing needs to change in this PR.
enzoduarte1 commented 2026-11-24 06:55:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by enzoduarte1 on 2026-11-24T03:34:54Z.


Thanks for checking this. Agreed: if PR 241 lands first, this change is redundant and can be closed; otherwise it can land on its own and PR 241 can drop its copy of the filter. I will leave the call to the maintainers — nothing needs changing here.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121230672 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/363#issuecomment-7121230672). Originally posted by [enzoduarte1](https://github.com/enzoduarte1) on 2026-11-24T03:34:54Z. --- Thanks for checking this. Agreed: if PR 241 lands first, this change is redundant and can be closed; otherwise it can land on its own and PR 241 can drop its copy of the filter. I will leave the call to the maintainers — nothing needs changing here.
mercuryVM commented 2026-11-24 08:02:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T07:37:39Z.

Review: APPROVED


Tested 4874c3f on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (265 passed, 0 failed).

An empty VICTORY_CONFIG now means unset, the same rule the other path variables in resolve already follow (env_path filters empty values). A non-empty value is still taken as the exact file, so a mistyped path still fails loudly. The helper takes the env lookup as a closure, matching how resolve is tested.

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6035357327 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/363#pullrequestreview-6035357327). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T07:37:39Z. **Review:** APPROVED --- Tested 4874c3f on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (265 passed, 0 failed). An empty `VICTORY_CONFIG` now means unset, the same rule the other path variables in `resolve` already follow (`env_path` filters empty values). A non-empty value is still taken as the exact file, so a mistyped path still fails loudly. The helper takes the env lookup as a closure, matching how `resolve` is tested. No issues found. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 01:03:30 +00:00
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!363
No description provided.