Failure binding to ODataV4

Hi,

I'm having almost exact same problem as this previous thread https://www.syncfusion.com/forums/161874/odatav4-binding-with-embedded-object which was attributed to a problem with binding to ExpandoObject, and apparently resolved.

Using current version (19.4.0.42). The following code:

    <SfTreeGrid TValue="OrgUnit" IdMapping="Id" ParentIdMapping="ParentId" HasChildMapping="HasChild" TreeColumnIndex="0">

        <SfDataManager @ref="dm" Url="odata/OrgUnits" Adaptor="Adaptors.ODataV4Adaptor" />
        <TreeGridEditSettings AllowEditing="true"/>
        <TreeGridColumns>
            <TreeGridColumn Field="@nameof(ou.Name)" />
            <TreeGridColumn Field="@nameof(ou.Type)" Width="80" />
            <TreeGridColumn Field="@nameof(ou.Id)" HeaderText="Id" Width="80" TextAlign="TextAlign.Right" IsPrimaryKey="true"/>
            <TreeGridColumn Field="@nameof(ou.Acronym)" Width="80" />
            <TreeGridColumn Field="@nameof(ou.AcronymPath)" HeaderText="Path1" Width="140" />
        </TreeGridColumns>
    </SfTreeGrid>

Generates error (then loops generating this error about 500/sec):

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: 'A' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
System.Text.Json.JsonException: 'A' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
 ---> System.Text.Json.JsonReaderException: 'A' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
   at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
   at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1[[System.Byte[], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1[[System.Byte[], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.JsonConverter`1[[System.Byte[], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCoreAsObject(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[Object](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpan[Object](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)
   at Syncfusion.Blazor.Internal.SfBaseUtils.ChangeType(Object dataValue, Type conversionType, Boolean isClientChange, Boolean isParseValue)
   at Syncfusion.Blazor.TreeGrid.Internal.TreeGridutils`1[[Sirrus.Shared.OrgUnit, Sirrus.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetEventArgsData(Object treeData, String childMapping, Type dataType, SfTreeGrid`1 parent)
   at Syncfusion.Blazor.TreeGrid.Internal.TreeGridutils`1[[Sirrus.Shared.OrgUnit, Sirrus.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ConvertToTreeGridArgs(Object gridArgs, Object treeGridArgs, SfTreeGrid`1 parent)
   at Syncfusion.Blazor.TreeGrid.Internal.GridRenderer`1.<RowDataBoundHandler>d__65[[Sirrus.Shared.OrgUnit, Sirrus.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Syncfusion.Blazor.Grids.Internal.GridRowBase`1.<OnParametersSetAsync>d__70[[System.Dynamic.ExpandoObject, System.Linq.Expressions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
I'm not using ExpandoObject. My datasource (odata/Orgunits) is just a self referencing dataset that includes Id, ParentId and HasChild.

If I retrieve the odata separately & supply same to SfTreeGrid, works OK. Just if I use SfDataManager to ODataV4 it fails.

Please advise.



12 Replies

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team January 17, 2022 03:44 PM UTC

Hi Phil, 

We are working on this query with high Priority and provide you further details by on or before 19th January 2022

In the meanwhile we request to share the following details for further validation. 

  1. Have you faced the issue while using ODataV4 Adaptor along with Complex binding?
  2. Screenshot/Video demo to replicate the issue.
  3. Have you faced the issue only on 19.4.0.42 version.
  4. If possible share us the simple issue replicable sample and revert us back.


Regards, 
Farveen sulthana T 



PH Phil Holmes January 19, 2022 06:22 AM UTC

Hi Farveen,

  1. No, as I'm just using flat self-referencing dataset.
  2. See later
  3. Have updated to 0.43 also now, same problem.
  4. see below

In attempting to prepare a sample to replicate issue for you, I have isolated the triggering issue. My dataset includes an SQL timestamp column (SysTS) which is the EF class translates to byte[]. When this field is populated, it seems SfTreeGrid fails if bound to SfDataManager. Note, all my datasets have this column, as they are all SQL Server sourced. SfDataGrid has no problem. SfTreeGrid fails. If the SysTS column is null, SfTreeGrid is OK. If it is populated, even if not being referenced in a column, it fails.

Note also, if the same data is supplied to the SfTreeGrid via separate handling (i.e. not bound SfDataManager), SfTreeGrid handles OK. So there is some problem with interaction between SfTreeGrid & SfDataManager. Again, SfDataManager + SfDataGrid + populated Byte[] field = OK!

So the EF data class is: 

public class OrgUnit2 {


      public OrgUnit2() { }

      public int Id { get; set; }

      public byte[] SysTS { get; set; }

      public int? ParentId { get; set; }

      public string Name { get; set; }

      public string Type { get; set; }

      public int GlSetClient { get; set; }

      public int GlSetAdmin { get; set; }

      public int TemplateSet { get; set; }

      public int PeriodSet { get; set; }

      public string NewAccountTemplate { get; set; }

      public string AccountMaskPrefix { get; set; }

      public int AccountMaskDigits { get; set; }

      public string Acronym { get; set; }

      public string AcronymPath { get; set; }

      public DateTime Created { get; set; }

      public int CreatedBy { get; set; }

      public DateTime LastModified { get; set; }

      public int LastModifiedBy { get; set; }

      public bool? HasChild { get; set; }

      public string CreatedByName { get; set; }

      public string LastModifiedByName { get; set; }

   }

Here is a sample returned JSON record that causes SfDataManger + SfTreeGrid to fail:

https://localhost:5001/odata/OrgUnits?$count=true&$filter=ParentId%20eq%20null
{
    "@odata.context""https://localhost:5001/odata/$metadata#OrgUnits",
    "@odata.count"1,
    "value": [
        {
            "Id"12,
            "SysTS""AAAAAAJ+tBk=",
            "ParentId"null,
            "Name""Test Platform",
            "Type""Platform",
            "GlSetClient"2,
            "GlSetAdmin"2,
            "TemplateSet"1,
            "PeriodSet"1,
            "NewAccountTemplate"null,
            "AccountMaskPrefix""T",
            "AccountMaskDigits"5,
            "Acronym""Test",
            "AcronymPath""Test.",
            "Created""2021-11-25T11:45:36.85+11:00",
            "CreatedBy"31,
            "LastModified""2021-11-25T11:45:36.867+11:00",
            "LastModifiedBy"31,
            "HasChild"true,
            "CreatedByName""Phil Holmes (Mont)",
            "LastModifiedByName""Phil Holmes (Mont)"
        }
    ]
}

but the following is OK:

{
    "@odata.context""https://localhost:5001/odata/$metadata#OrgUnits",
    "@odata.count"1,
    "value": [
        {
            "Id"12,
            "ParentId"null,
            "Name""Test Platform",
            "Type""Platform",
            "GlSetClient"2,
            "GlSetAdmin"2,
            "TemplateSet"1,
            "PeriodSet"1,
            "NewAccountTemplate"null,
            "AccountMaskPrefix""T",
            "AccountMaskDigits"5,
            "Acronym""Test",
            "AcronymPath""Test.",
            "Created""2021-11-25T11:45:36.85+11:00",
            "CreatedBy"31,
            "LastModified""2021-11-25T11:45:36.867+11:00",
            "LastModifiedBy"31,
            "HasChild"true,
            "CreatedByName""Phil Holmes (Mont)",
            "LastModifiedByName""Phil Holmes (Mont)"
        }
    ]
}





FS Farveen Sulthana Thameeztheen Basha Syncfusion Team January 19, 2022 04:06 PM UTC

Hi Phil, 

We appreciate your patience. 

Query#:- If I retrieve the odata separately & supply same to SfTreeGrid, works OK. Just if I use SfDataManager to ODataV4 it fails. 

We have prepared sample with SfTreeGrid + SfDataManager but we are unable to replicate the problem at our end. Refer to the sample link below:- 

Code example:- 
Index.razor:- 
 
<SfTreeGrid TValue="Order" @ref="TreeGrid" IdMapping="TaskId" ParentIdMapping="ParentId" TreeColumnIndex="1" HasChildMapping="isParent"> 
    <SfDataManager Url=http://localhost:64956/odata/books Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager> 
    <TreeGridColumns> 
        <TreeGridColumn Field="@nameof(Order.TaskId)" HeaderText="Task ID" Width="80" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right"></TreeGridColumn> 
              .    .   .  
    </TreeGridColumns> 
</SfTreeGrid> 
 
[Route("api/[controller]")] 
    public class BooksController : ODataController 
    { 
        private BookStoreContext _db; 
 
 
        public BooksController(BookStoreContext context) 
        { 
            _db = context; 
            if (context.Books.Count() == 0) 
            { 
                context.Books.AddRange(DataSource.GetBooks()); 
            } 
            context.SaveChanges(); 
        } 
        // GET api/values 
        [HttpGet] 
        [EnableQuery] 
        //[System.Web.Http.AllowAnonymous] 
        public IActionResult Get() 
        { 
            return Ok(_db.Books); 
        } 
    } 

   public class Book 
    { 
        [Key] 
        public int TaskId { get; set; } 
 
        public byte[] SysTS { get; set; } 
        public string TaskName { get; set; } 
        public int Duration { get; set; } 
        public int Progress { get; set; } 
        public string Priority { get; set; } 
        public int? ParentId { get; set; } 
 
        public bool? isParent { get; set; } 
    } 

We have prepared a sample using ODataV4 adaptor, where application consist of two projects. One project BlazorApp consist of TreeGrid definition, where ODataV4Service project handles the server side actions (ODataV4 controller).Along with this, we have included public byte[] SysTS { get; set; } in DataModel. 
 
Screenshot:- 
 

So we request to replicate the issue in the simple application attached and Video Demo to replicate the issue to proceed further. 

Regards, 
Farveen sulthana T 



PH Phil Holmes January 20, 2022 01:16 AM UTC

Hi Farveen,

Thanks for trying, but your example leaves out the SysTS property in the client side class, which I had advised was triggering the problem in the interaction between SfTreeGrid & SfDataManager. While you have added it into the controller on the server side, its not called upon in your client side at all, hence your example works.

In real-use-case, SysTS is needed in the full client-server loop as it is an SQL concurrency field.

Here is complete example that is failing as described.

Please advise.


Regards,

Phil


Attachment: DemoFail_(Send)_86ea406d.zip


FS Farveen Sulthana Thameeztheen Basha Syncfusion Team January 20, 2022 03:52 PM UTC

Hi Phil, 

Thanks for your additional details. 

We are able to replicate the problem with ODataV4 Adaptor with  public byte[] SysTS { get; set; } in DataModel. We will validate the reported problem with high Priority and provide you further details by on or before 25th January 2022.  
 
Until then we appreciate your patience. 

Regards, 
Farveen sulthana T 



FS Farveen Sulthana Thameeztheen Basha Syncfusion Team January 25, 2022 04:24 PM UTC

 Hi Phil, 

Sorry for the inconvenience caused. 

Due to some complexities, we need time to validate this issue at our end and will update further details by on or before 28th January 2022. Until then we value your patience. 

Regards, 
Farveen sulthana T 



FS Farveen Sulthana Thameeztheen Basha Syncfusion Team January 31, 2022 07:07 AM UTC

Hi Phil, 

We appreciate your patience and apologizes for the delay. 

Further analyzing, we have confirmed it as a bug and logged the defect report for the same “Exception throws while using ODataV4 Adaptor populated with Byte[] field ”. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technical feasibility and Product Development Life Cycle ) and this issue fix will be included in the February 3rd week patch release (16th February 2022). Until then we appreciate your patience. 
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.
https://www.syncfusion.com/feedback/32279/exception-throws-while-using-odatav4-adaptor-populated-with-byte-field 
 
Disclaimer: The feedback link is in review state and you can view it once it is validated. 
 
Regards, 
Farveen sulthana T 



PH Phil Holmes February 16, 2022 09:07 AM UTC

Hi,

I note that this does not appear to have yet been rectified in the patch planned (today).

Also, for the guys working on this, I seem to experience a similar problem with the call to SfDataManager update, fails with similar client size failing, with no call being made to service endpoint to make the update.

Would be great if when they test this fix, they also include testing all CRUD operations, as I don't think it is only the read operation that is failing.

Regards,

Phil



FS Farveen Sulthana Thameeztheen Basha Syncfusion Team February 17, 2022 04:48 PM UTC

Hi Phil, 

Sorry for the inconvenience caused. 

Due to unforeseen circumstances the fix for the issue “Exception throws while using ODataV4 Adaptor populated with Byte[] field” couldn't be included in that patch release as we promised. The fix for the same will be rolled out by next week patch release which is expected to be February 23rd 2021. 

Also share details about the issue you have faced while performing CRUD actions.(code example, Video Demo or Issue replication sample)  which will be more helpful for further validation and provide you solution earlier. 

Regards,
Farveen sulthana T 



FS Farveen Sulthana Thameeztheen Basha Syncfusion Team February 24, 2022 04:03 PM UTC

Hi Phil,  

Sorry for the inconvenience caused.  

Due to unforeseen circumstances the fix for the issue “Exception throws while using ODataV4 Adaptor populated with Byte[] field” couldn't be included in that patch release as we promised. The fix for the same will be rolled out by  upcoming patch release which is expected to be March 9, 2022 .  

Also share details requested on previous update for CRUD related functionalities for validation. 

Regards, 
Farveen sulthana T 



PH Phil Holmes March 2, 2022 08:25 AM UTC

Hi Farveen,


Its a bit hard to provide code example of the CUD operations failure, when you haven't yet released the fix for the R failure. Only once one reads the data, can they then attempt updating it also.


I had tried a few temporary workarounds to the problem, when led me to think the problem also exists in updating data, not just reading it. Hence my request that when you fix the 1st (read) problem, your QA guys also test CUD operations prior to release. I would have hoped this would be normal regression practice, but just in case not, I asked this.

You have already verified the read problem. All I am asking is in your pre-release QA, please check CUD operations also. That would be much easier than me providing whole workaround code for you to QA.

I look forward to next week's patch then.

Regards,

Phil



FS Farveen Sulthana Thameeztheen Basha Syncfusion Team March 2, 2022 04:09 PM UTC

Hi Phil, 
 
Thanks for your feedback. 

We will ensure the case (with CRUD operation) while on fixing the Bug and will included in our Volume 1, Main release.  In the meanwhile we will contact you if any details required.  
 
Until then we appreciate your patience. 

Regards, 
Farveen sulthana T 


Loader.
Up arrow icon