inspect_instances fails the entire list when one instance has malformed metadata

Aperta
#257 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
backend

Direzione di ricerca

Start in crates/driver/src/inspect/installed.rs at InstalledInstance::detect_all, where the ? inside the loop aborts the scan, then follow InstanceProbe::collect in crates/driver/src/inspect/probe.rs and the wrapper Launcher::inspect_instances in crates/launcher/src/launcher.rs. Done means one malformed instance no longer hides the others and each failure carries the instance name or path; the API shape (report struct or per-item Result) needs a maintainer decision first, and inspect_instance(name) stays fail-fast.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

Launcher::inspect_instances() is all-or-nothing. A single unreadable or malformed instance metadata file makes the whole call return Err, so callers cannot list the remaining healthy instances or identify which instance is broken.

Where
  • crates/launcher/src/launcher.rs:114 — Launcher::inspect_instances collects Result<Vec<InstalledInstance>>.

  • crates/driver/src/inspect/installed.rs:43 — InstalledInstance::detect_all uses ? inside the loop:

    for instance in storage.instances(version_layout)? {
        if let Some(installed) = Self::detect(instance, drivers).await? {
            instances.push(installed);
        }
    }
    
  • crates/driver/src/inspect/probe.rs:23 — InstanceProbe::collect opens and parses the version JSON:

    Ok(serde_json::from_reader(File::open(path)?)?)
    

A truncated or invalid <version>.json, an unreadable file, or a read_dir failure aborts the whole scan.

Impact

A launcher UI typically calls inspect_instances to render the installed-instance list. One corrupt instance file in .minecraft/versions hides every other instance. The user cannot select a healthy instance, nor see which entry needs repair or removal. The returned error also has no instance name or path attached, so the caller cannot tell which directory caused it.

Reproduction
  1. Create two valid instances (a, b).
  2. Truncate or corrupt versions/a/a.json (or otherwise make it invalid JSON).
  3. Call Launcher::inspect_instances().await.
  4. Observe Err(...); b is not returned.
Proposal

Make the aggregate scan report per-instance failures instead of aborting, for example:

pub struct InspectReport {
    pub instances: Vec<Instance>,
    pub failures: Vec<InstanceInspectionFailure>,
}

pub struct InstanceInspectionFailure {
    pub instance_name: String,
    pub path: PathBuf,
    pub error: Error,
}

Alternatively, return Vec<Result<Instance, InstanceInspectionError>>. The important part is that one bad instance does not hide the rest, and the failure includes the instance name or path. Skipping invalid entries with only a log is less useful for a UI that wants to offer repair or delete actions.

inspect_instance(name) can remain fail-fast because it targets one known instance.

Version

main at b4d6e84.

Lingua principale
Rust
Stelle
11
Fork
1
Merge medio
3h 32m
PR unite (30g)
52

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ElectronicWave/Elemental

Tutte le issue di ElectronicWave/Elemental

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.