fix(gui): paths::tests::missing_files_yield_defaults fails on main (got Some(""))
- 主要语言
- Rust
- 星标
- 0
- 派生
- 0
- 平均合并
- 50 分钟
- 30 天内合并 PR
- 48
描述
## Summary
Pre-existing test failure on `main` (commit `a5a7faa`). Discovered while validating issue #160 — `make ci` (which mirrors the .github/workflows/ci.yml cargo invocations) fails on this test on a clean checkout.
## Repro
```
cargo test --locked -p telora-gui missing_files_yield_defaults
```
## Output
```
running 1 test
test paths::tests::missing_files_yield_defaults ... FAILED
thread 'paths::tests::missing_files_yield_defaults' panicked at telora-gui/src/paths.rs:281:9:
missing files + no env vars must leave socket_dir unset (got Some(""))
```
## Expected
`cfg.socket_dir.is_none()` to be true.
## Actual
`cfg.socket_dir` is `Some("")`. The test removes the env vars `TELORA_PATHS__SOCKET_DIR`, `TELORA_PATHS__DAEMON_SOCKET`, `TELORA_PATHS__CONTROL_SOCKET` (telora-gui/src/paths.rs:275-277) and removes `HOME` if it wasn't set initially (lines 256-265), then sets `HOME` to a tempdir. With the config file missing, `load_paths_config` should return `socket_dir = None`, but it returns `Some("")` instead.
## Likely root cause
Probably in the `config` crate's `config-file merge logic` — when no file is present and no env var is set, the default field value (likely `""`) leaks through instead of being treated as absent. `paths::Config` derives `Default` (telora-gui/src/paths.rs) and merges with config file; the merge probably preserves the default empty string.
## Suggested fix
Either:
1. Use `#[serde(default, deserialize_with = "...")]` to convert empty strings to `None` at deserialize time.
2. Have `load_paths_config` post-process the merged config and replace empty-string optionals with `None`.
3. Change the `PathsConfig` struct so `socket_dir` is `Option` with explicit `None` default rather than relying on `Default` to produce `None` from `""` via the `config` crate's merge.
## Out of scope for issue #160
The Makefile expansion in #160 does not touch `telora-gui` source. This failure pre-dates the Makefile work and is reproducible on a clean `main` checkout. Filed as a separate bug.
贡献指南
评估
这个 Issue 还没有评估数据。