umbraco-community / Umbraco.Community.Sustainability

A package from the Umbraco Community Sustainability Team which helps developers and editors see and improve the carbon impact of their websites.
MIT License
9 stars 9 forks source link

Json deserialization error on resources.redirectStart property #35

Open Warren-CabEngine opened 2 months ago

Warren-CabEngine commented 2 months ago

Which Umbraco.Community.Sustainability version are you using?

1.0.4

Which Umbraco version are you using? For example: 10.8.0 - don't just write v10

13.5.1

Bug summary

This is my first time installing and running this package. Clicking "Run sustainability report" fails with this error:

image

The issue appears to be with this field: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/redirectStart. Within this package it tries to deserialize the value to an int from looking at the SustainabilityData model class, but the Mozilla docs state that this field is a timestamp which is a double.

Steps to reproduce

An error occurred

The JSON value could not be converted to System.Int32. Path: $.resources[7].redirectStart | LineNumber: 0 | BytePositionInLine: 5673.
Exception Details
System.Text.Json.JsonException, System.Text.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51: The JSON value could not be converted to System.Int32. Path: $.resources[7].redirectStart | LineNumber: 0 | BytePositionInLine: 5673. 

at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at Umbraco.Community.Sustainability.Services.SustainabilityService.GetSustainabilityData(String url)
at Umbraco.Community.Sustainability.Services.SustainabilityService.GetSustainabilityData(String url)
at Umbraco.Community.Sustainability.Controllers.SustainabilityController.CheckPage(Guid pageKey)

Expected result / actual result

Should successfully generate a report, but instead it errors.