Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentOutOfRangeException When Reference Field is Unset on Content #150

Open
HegyiOliver opened this issue Aug 5, 2024 · 0 comments
Open

Comments

@HegyiOliver
Copy link

An ArgumentOutOfRangeException occurs when executing a SenseNet client query function like Task<IContentCollection<Content>> QueryAsync(QueryContentRequest requestData, CancellationToken cancel). This error is triggered if any of the collected content's selected reference fields are not set.

My Query Details

  • Expand Fields: ArticleReference
  • Select Fields:
    Path, Type, Name, Id, DisplayName, ParentPath, Hidden, Index,
    ArticleReference/Path, ArticleReference/Type, ArticleReference/Name,
    ArticleReference/Id, ArticleReference/DisplayName, ArticleReference/ParentPath,
    ArticleReference/Hidden, ArticleReference/Index, LinkOpenType, Alt, Title,
    Href, HrefTitle, Description
    

Probable Cause

The error is likely thrown in the method SenseNet.Client.Repository.CreateContentFromResponse(Object jObject, Type defaultContentType).

Stack Trace

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at Newtonsoft.Json.Linq.JContainer.GetItem(Int32 index)
   at Newtonsoft.Json.Linq.JArray.get_Item(Int32 index)
   at SenseNet.Client.Content.GetReference(Object input, Type propertyType)
   at SenseNet.Client.Content.SetProperties(Object responseContent)
   at CallSite.Target(Closure, CallSite, Content, Object)
   at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1)
   at CallSite.Target(Closure, CallSite, Content, Object)
   at SenseNet.Client.Content.InitializeFromResponse(Object responseContent)
   at CallSite.Target(Closure, CallSite, Content, Object)
   at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1)
   at CallSite.Target(Closure, CallSite, Content, Object)
   at SenseNet.Client.Repository.CreateContentFromResponse(Object jObject, Type defaultContentType)
   at SenseNet.Client.Repository.CreateContentFromResponse[T](Object jObject)
   at System.Linq.Enumerable.SelectIListIterator`2.Fill(IList`1 source, Span`1 results, Func`2 func)
   at System.Linq.Enumerable.SelectIListIterator`2.ToArray()
   at SenseNet.Client.Repository.LoadCollectionAsync[T](ODataRequest requestData, CancellationToken cancel)
   at [MyContentClass]

Steps to Reproduce

  1. Create a query with the specified expand and select fields.
  2. Execute the query using QueryAsync method.
  3. Ensure at least one of the collected content's reference fields is unset.
  4. Observe the ArgumentOutOfRangeException thrown.

Expected Behavior

The query should handle cases where reference fields are unset without throwing an exception.

Environment

  • Library Version: [SenseNet.Client, Version=3.0.7.2]
  • .NET Version: [8.0]

This version includes a clear structure, detailed description, probable cause, and steps to reproduce the issue, making it easier for the maintainers to understand and address the problem.

@HegyiOliver HegyiOliver added the bug label Aug 5, 2024
@HegyiOliver HegyiOliver changed the title ArgumentOutOfRangeException When Reference Field is Unset in Query ArgumentOutOfRangeException When Reference Field is Unset on Content Aug 5, 2024
@kavics kavics added the client label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants