{"record":{"id":"513aa25ee4d6521d","repo":"jdx/mise","slug":"affected-project-exists-in-graph","errorCode":null,"errorMessage":"affected project exists in graph","messagePattern":"affected project exists in graph","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/run.rs","lineNumber":450,"sourceCode":"\n#[derive(Serialize)]\nstruct AffectedTaskOutput<'a> {\n    name: &'a str,\n    projects: Vec<&'a crate::task::workspace::ProjectId>,\n}\n\nfn display_affected_json(\n    revisions: &crate::task::workspace::git::WorkspaceGitRevisions,\n    workspace_root: &std::path::Path,\n    graph: &crate::task::workspace::WorkspaceProjectGraph,\n    affected: &crate::task::workspace::AffectedProjects,\n    tasks: &[Task],\n) -> Result<()> {\n    let mut projects_by_root = BTreeMap::<PathBuf, Vec<_>>::new();\n    let projects = affected\n        .projects()\n        .map(|(id, reasons)| {\n            let project = graph.get(id).expect(\"affected project exists in graph\");\n            projects_by_root\n                .entry(crate::file::desymlink_path(\n                    &workspace_root.join(&project.root),\n                ))\n                .or_default()\n                .push(id);\n            AffectedProjectOutput {\n                id,\n                root: &project.root,\n                reasons,\n            }\n        })\n        .collect();\n    let mut tasks = tasks\n        .iter()\n        .map(|task| AffectedTaskOutput {\n            name: &task.display_name,\n            projects: task","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/cli/run.rs#L432-L468","documentation":"`mise run --affected` (experimental monorepo workspaces) computes the set of affected projects from git revisions and then renders machine-readable JSON. Every affected project id was produced by enumerating the same WorkspaceProjectGraph, so `graph.get(id)` in display_affected_json must succeed; the expect asserts the AffectedProjects set and the graph passed to the renderer stayed in sync (src/cli/run.rs:450-462).","triggerScenarios":"Only if the affected set and the graph handed to display_affected_json come from different builds/refreshes of the workspace graph — e.g. a refactor caches or recomputes the graph between computation and display. User-side flag combinations (--affected with revisions, --json) always pass the same graph instance.","commonSituations":"Contributors changing workspace graph caching/incremental refresh; users on experimental monorepo builds after a mid-run workspace change (added/removed project) is theoretically where a stale-graph refactor bug would show.","solutions":["If hit: rerun `mise run --affected` — a transient workspace/graph race in an experimental feature; update to the latest mise","Disable the experimental workspace feature (settings: experimental = false) if it recurs","As a contributor: derive AffectedProjects and the display graph from the same graph instance; never rebuild between compute and render","Report at https://github.com/jdx/mise/issues with the workspace layout and revisions used"],"exampleFix":"// before: graph recomputed between affected computation and display\nlet affected = compute_affected(&graph_refresh().await?, revs);\ndisplay_affected_json(revs, root, &graph_refresh().await?, &affected, tasks)?; // ids may not exist -> panic\n\n// after: one graph instance flows through both\nlet graph = workspace_graph().await?;\nlet affected = compute_affected(&graph, revs);\ndisplay_affected_json(revs, root, &graph, &affected, tasks)?;","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Rerun mise run --affected on transient failures; keep workspace graph inputs stable during a run","Disable experimental workspace features if --affected repeatedly misbehaves","Report reproducible cases with the exact revisions and workspace layout"],"tags":["workspace","monorepo","affected","invariant","panic","internal"],"backgroundTag":"internal-invariant-violation","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}