inspect_instances fails the entire list when one instance has malformed metadata

Open
#257 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
backend

Research direction

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.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Rust
Stars
11
Forks
1
Avg merge
3h 32m
Merged PRs (30d)
52

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ElectronicWave/Elemental

All issues in ElectronicWave/Elemental

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.