fix(gui): paths::tests::missing_files_yield_defaults fails on main (got Some(""))
- 主要言語
- Rust
- スター
- 0
- フォーク
- 0
- 平均マージ
- 48分
- マージ済み PR(30日)
- 51
説明
## 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.
コントリビューションガイド
調査の方向性
Start in telora-gui/src/paths.rs, especially load_paths_config and paths::tests::missing_files_yield_defaults, then run cargo test --locked -p telora-gui missing_files_yield_defaults. Trace how the missing config file and removed environment variables produce Some("") for socket_dir. Done means the test passes with cfg.socket_dir set to None.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rust
- 領域
- desktop
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 活発
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 72/100