airvzxf / airvzxf/telora

fix(gui): paths::tests::missing_files_yield_defaults fails on main (got Some(""))

Abierto
#161 0 comentarios 0 reacciones 0 asignados Ver en GitHub
bug pending-tracking
Lenguaje dominante
Rust
Estrellas
0
Forks
0
Merge medio
48 min
PR fusionados (30 d)
51

Descripción

## 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.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
rust
Área
desktop
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Activo
Claridad
Bastante claro
Aptitud para principiantes
72/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.