Repository navigation
Description
Current behavior
RocmCliConfig::load deliberately distinguishes a missing config (returns defaults) from an unreadable one (returns an error). record_managed_python_config (apps/rocm/src/therock.rs) collapses the two and then saves:
let mut config = RocmCliConfig::load(paths).unwrap_or_default();
config.tools.insert("python".to_owned(), …);
config.save(paths)Both callers discard the result with let _ =. So a config that is merely unreadable is replaced on disk with an otherwise-empty one, and nothing is reported.
What is lost
Everything the user configured: the active and default runtime, the TheRock folder setting, providers, the permissions mode, engine preferences, and dashboard chat settings. The next command sees a valid, empty config and carries on.
Expected behavior
An unreadable config is reported, not replaced. Recording the managed Python should either fail loudly or leave the file untouched.
How a user gets here
The config only has to be unreadable at the moment the CLI bootstraps its own Python — the first rocm install sdk or update on a machine whose system Python cannot create a virtual environment (common on Windows, and on Linux without python3-venv).
A config becomes unreadable more easily than it should, because RocmCliConfig::save uses a plain fs::write, which truncates before writing. A full disk during a multi-gigabyte install produces precisely a truncated config.json. Every corruption class tested is wiped: a truncated write, a non-finite number serialised as null, a field of the wrong type, and an out-of-range value load rejects.
Steps to reproduce
Truncate config.json to one byte, then trigger managed-Python recording. The file afterwards loads cleanly as defaults.
Related, same root
configured_managed_root_from_configreads the same file with.ok()?, so when the config is unreadable the data directory silently falls back to the default. A user who installed with--prefixthen sees no runtimes — and once the wipe above erasessetup.therock_venv, the relocation becomes permanent.- Dashboard tick fields are
f64;serde_jsonwrites NaN/±inf asnull, whichloadrejects. The legacy rocm-dash TOML migration copies those ticks unchecked, sodiscovery_tick = nanin an old config migrates into aconfig.jsonthat cannot be loaded — and then the wipe above discards the migrated settings, while migration never runs again becauseconfig.jsonnow exists. - Several other writes (
save_runtime_manifest,write_active_runtime_marker) are not atomic either, while the least important file, the startup update-check cache, is written atomically.
Environment
- Built from
main. Platform-independent.
How it was found
Property-testing persisted-state round-trips: the property "corruption is never silently converted into a different valid state" failed for every corruption class.
Activity
fix(core): save config.json atomically and only if it loads back
fix(core): refuse legacy dashboard ticks that rocm-dash rejects
fix(core): stop guessing the data dir from an unreadable config.json
fix(therock): never replace an unreadable config.json with defaults
fix(core): save config.json atomically and only if it loads back
fix(core): refuse legacy dashboard ticks that rocm-dash rejects
fix(core): stop guessing the data dir from an unreadable config.json
fix(therock): never replace an unreadable config.json with defaults
fix(core): save config.json atomically and only if it loads back
fix(core): refuse legacy dashboard ticks that rocm-dash rejects
fix(core): stop guessing the data dir from an unreadable config.json
fix(therock): never replace an unreadable config.json with defaults
fix(core): save config.json atomically and only if it loads back
fix(core): refuse legacy dashboard ticks that rocm-dash rejects
7 remaining items
fix(core): refuse legacy dashboard ticks that rocm-dash rejects
fix(core): stop guessing the data dir from an unreadable config.json
fix(therock): never replace an unreadable config.json with defaults
fix(core): save config.json atomically and only if it loads back
fix(core): refuse legacy dashboard ticks that rocm-dash rejects
fix(core): stop guessing the data dir from an unreadable config.json
fix(therock): never replace an unreadable config.json with defaults
fix(core): save config.json atomically and only if it loads back
fix(core): refuse legacy dashboard ticks that rocm-dash rejects
fix(core): stop guessing the data dir from an unreadable config.json
fix(therock): never replace an unreadable config.json with defaults
fix(core): save config.json atomically and only if it loads back
fix(core): refuse legacy dashboard ticks that rocm-dash rejects
fix(core): stop guessing the data dir from an unreadable config.json
fix(therock): never replace an unreadable config.json with defaults