Skip to content

Commit 8444b50

Browse files
committed
fix(model-library): remove artifact resolver unwrap
Replace the guarded unwrap in selected-artifact path resolution with direct iterator matching so production request handling stays panic-free while preserving zero, one, and many match behavior. Record the Pantograph standards cleanup in the artifact load-target plan issue register. Verification: cargo fmt --manifest-path rust/Cargo.toml --all; cargo test --manifest-path rust/Cargo.toml -p pumas-library read_only_library; cargo test --manifest-path rust/Cargo.toml -p pumas-library artifact_owner_fresh; cargo test --manifest-path rust/Cargo.toml -p pumas-library --test artifact_load_target_contract_fixtures; cargo check --manifest-path rust/Cargo.toml -p pumas-library; git diff --check
1 parent 6a0df9c commit 8444b50

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

docs/plans/pumas-artifact-load-target-resolution/plan.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ targets to workers.
243243
now rejects requests with no selected artifact identity, resolves a missing
244244
`selected_artifact_id` from a unique indexed `selected_artifact_path`, and
245245
reports typed diagnostics for missing or ambiguous path matches.
246+
- M2-003 closed: Pantograph review found a guarded production `unwrap()` in
247+
selected-artifact path resolution. The resolver now expresses the zero,
248+
one, and many match cases by matching iterator results directly.
246249

247250
## Risks And Mitigations
248251
| Risk | Mitigation |

rust/crates/pumas-core/src/model_library/artifact_load_target.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,13 @@ fn selected_artifact_id_from_path(
144144
index.list_model_package_facts_cache(model_id, ModelPackageFactsCacheScope::Detail)?,
145145
);
146146

147-
match matches.len() {
148-
0 => Ok(SelectedArtifactIdentity::PathNotIndexed),
149-
1 => Ok(SelectedArtifactIdentity::Resolved(
150-
matches.into_iter().next().unwrap(),
151-
)),
152-
_ => Ok(SelectedArtifactIdentity::AmbiguousPath),
147+
let mut matches = matches.into_iter();
148+
match (matches.next(), matches.next()) {
149+
(None, _) => Ok(SelectedArtifactIdentity::PathNotIndexed),
150+
(Some(selected_artifact_id), None) => {
151+
Ok(SelectedArtifactIdentity::Resolved(selected_artifact_id))
152+
}
153+
(Some(_), Some(_)) => Ok(SelectedArtifactIdentity::AmbiguousPath),
153154
}
154155
}
155156

0 commit comments

Comments
 (0)