From 5887396cb9e1a0ce2998af35fe93db2457d0ee41 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Wed, 29 Oct 2025 16:28:03 +0200 Subject: [PATCH 1/2] Fix parsing objects that have properties with empty name Move to utils Typo Clean up --- utils/Integration.TestUtils.psm1 | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/utils/Integration.TestUtils.psm1 b/utils/Integration.TestUtils.psm1 index 0c4b0c8..9fee493 100644 --- a/utils/Integration.TestUtils.psm1 +++ b/utils/Integration.TestUtils.psm1 @@ -1,5 +1,33 @@ # PowerShell module containing utility functions for Sentry console integration tests +function script:Convert-HashtableToObject { + [CmdletBinding()] + param( + [Parameter(Mandatory = $false)] + $Item + ) + + if ($null -eq $Item) { + return $null + } + + if ($Item -is [System.Collections.IDictionary]) { + $obj = [PSCustomObject]@{} + foreach ($key in $Item.Keys) { + if ([string]::IsNullOrWhiteSpace($key)) { + # Skip properties with empty or whitespace-only names + continue + } + $obj | Add-Member -NotePropertyName $key -NotePropertyValue (Convert-HashtableToObject $Item[$key]) + } + return $obj + } elseif ($Item -is [System.Collections.IEnumerable] -and -not ($Item -is [string])) { + return @($Item | ForEach-Object { Convert-HashtableToObject $_ }) + } else { + return $Item + } +} + function Invoke-CMakeBuild { [CmdletBinding()] param( @@ -130,6 +158,17 @@ function Get-SentryTestEvent { } if ($sentryEvent) { + # Handles Sentry API responses with empty property names as these won't be converted to objects automatically + if ($sentryEvent -is [string]) { + try { + $raw = $sentryEvent | ConvertFrom-Json -Depth 50 -AsHashtable + $sentryEvent = Convert-HashtableToObject -Item $raw + } catch { + Write-Host "Failed to parse JSON from Sentry event: $($_.Exception.Message)" -ForegroundColor Red + return + } + } + Write-Host "Event $($sentryEvent.id) fetched from Sentry" -ForegroundColor Green $entries = $sentryEvent.entries $sentryEvent = $sentryEvent | Select-Object -ExcludeProperty 'entries' From b598e6c2969df00443e8194cee3081ecdc0d6fb2 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Wed, 29 Oct 2025 19:19:16 +0200 Subject: [PATCH 2/2] Fix naming --- utils/Integration.TestUtils.psm1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/Integration.TestUtils.psm1 b/utils/Integration.TestUtils.psm1 index 9fee493..7de4998 100644 --- a/utils/Integration.TestUtils.psm1 +++ b/utils/Integration.TestUtils.psm1 @@ -161,10 +161,10 @@ function Get-SentryTestEvent { # Handles Sentry API responses with empty property names as these won't be converted to objects automatically if ($sentryEvent -is [string]) { try { - $raw = $sentryEvent | ConvertFrom-Json -Depth 50 -AsHashtable - $sentryEvent = Convert-HashtableToObject -Item $raw + $hashtable = $sentryEvent | ConvertFrom-Json -Depth 50 -AsHashtable + $sentryEvent = Convert-HashtableToObject -Item $hashtable } catch { - Write-Host "Failed to parse JSON from Sentry event: $($_.Exception.Message)" -ForegroundColor Red + Write-Host "Failed to retrieve Sentry event object: $($_.Exception.Message)" -ForegroundColor Red return } }