akkadotnet / akkadotnet/Hyperion

Hyperion failed with "Index was out of range" in `GetDeserializedObject` when payload has Duplicate Values

Open
#52 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
281
Forks
62
PR merge metrics
No merged PRs in 30d

Description

My payload contains data like this in an FSharp Record. The error goes away if the values if the values are different. Only occurs when `preserve object refs` is true.

```
Section = Some "sd"
SubDivision = Some "sd"
```

This is the exception.

```
$exception {"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"} System.ArgumentOutOfRangeException
```

Here is the line that fails.

```
public class DeserializerSession
{
////
public object GetDeserializedObject(int id)
{
return _objectById[id]; // <- here
}
////
```

Stack Trace

```
> Hyperion.dll!Hyperion.DeserializerSession.GetDeserializedObject(int id = 14) Line 66 C#
Hyperion.dll!Hyperion.ValueSerializers.ObjectReferenceSerializer.ReadValue(System.IO.Stream stream = {System.IO.MemoryStream}, Hyperion.DeserializerSession session = {Hyperion.DeserializerSession}) Line 34 C#
Hyperion.dll!Hyperion.Extensions.StreamEx.ReadObject(System.IO.Stream stream = {System.IO.MemoryStream}, Hyperion.DeserializerSession session = {Hyperion.DeserializerSession}) Line 172 C#
```

Contributor guide

Open the contributing guide

Research direction

Start with DeserializerSession.GetDeserializedObject and trace the object-reference path through ObjectReferenceSerializer.ReadValue and StreamEx.ReadObject. Reproduce the failure using an F# record with duplicate Some values while preserve object refs is enabled; done means the payload deserializes without the reported index error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, fsharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.