Skip to content
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
27 changes: 19 additions & 8 deletions tools/clearlyDefined/src/ClearlyDefined/ClearlyDefined.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,30 @@ function ConvertFrom-ClearlyDefinedCoordinates {
[CmdletBinding()]
param(
[parameter(mandatory = $true, ValueFromPipeline = $true)]
[string]
[object]
$Coordinates
)
Comment on lines 42 to 45
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$Coordinates is now typed as [object], but the function no longer fails fast on $null (or unexpected object types). For example, $null input will take the else branch and return an object with all $null fields, which can later fail Start-ClearlyDefinedHarvest validation in a less obvious way. Consider adding ValidateNotNull() on the parameter and/or an explicit guard in Process that throws when $Coordinates is $null or does not contain the expected type/provider/namespace/name/revision fields (and similarly validate the split string has enough parts).

Copilot uses AI. Check for mistakes.

Begin {}
Process {
$parts = $Coordinates.Split('/')
[PSCustomObject]@{
type = $parts[0]
provider = $parts[1]
namespace = $parts[2]
name = $parts[3]
revision = $parts[4]
if ($Coordinates -is [string]) {
$parts = $Coordinates.Split('/')
[PSCustomObject]@{
type = $parts[0]
provider = $parts[1]
namespace = $parts[2]
name = $parts[3]
revision = $parts[4]
}
} else {
# Coordinates is already an object (e.g., from ClearlyDefined API response)
[PSCustomObject]@{
type = $Coordinates.type
provider = $Coordinates.provider
namespace = $Coordinates.namespace
name = $Coordinates.name
revision = $Coordinates.revision
}
}
}
End {}
Expand Down
Loading