Skip to content

change validation to throw instead of pre-condition to avoid crashes #6355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/Workspace/Workspace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1765,14 +1765,14 @@ extension Workspace {
// FIXME: This should be an ordered set.
requiredIdentities = inputIdentities.union(requiredIdentities)

let availableIdentities: Set<PackageReference> = Set(manifestsMap.map {
let availableIdentities: Set<PackageReference> = try Set(manifestsMap.map {
// FIXME: adding this guard to ensure refactoring is correct 9/21
// we only care about remoteSourceControl for this validation. it would otherwise trigger for
// a dependency is put into edit mode, which we want to deprecate anyways
if case .remoteSourceControl = $0.1.packageKind {
let effectiveURL = workspace.mirrors.effective(for: $0.1.packageLocation)
guard effectiveURL == $0.1.packageKind.locationString else {
preconditionFailure("effective url for \($0.1.packageLocation) is \(effectiveURL), different from expected \($0.1.packageKind.locationString)")
throw InternalError("effective url for \($0.1.packageLocation) is \(effectiveURL), different from expected \($0.1.packageKind.locationString)")
}
}
return PackageReference(identity: $0.key, kind: $0.1.packageKind)
Expand Down