Skip to main content
Solved

$expand with multiple items fails with "Index out of bounds" error

  • 19 July 2024
  • 3 replies
  • 23 views

Hello,

I am experiencing an error ("Index was outside the bounds of the array.") when trying to call multiple $expand items.

GET Query:

PX_Objects_SO_SOPickingWorksheet?$expand=SOPickerListEntryCollection($expand=InventoryItemByInventoryID,INToteByToteID)&$filter=WorksheetNbr eq '000001'

Response:
 

{
"error": {
"code": "",
"message": "An error has occurred.",
"innererror": {
"message": "Index was outside the bounds of the array.",
"type": "System.IndexOutOfRangeException",
"stacktrace": " at PX.Data.PXXmlDataRecord.GetBoolean(Int32 i)\r\n at PX.Data.SQLTree.ProjectionConst.GetValue(PXDataRecord data, Int32& position, MergeCacheContext context)\r\n at PX.Data.SQLTree.ProjectionInitNew.GetValue(PXDataRecord data, Int32& position, MergeCacheContext context)\r\n at PX.Data.SQLTree.ProjectionInitNew.GetValue(PXDataRecord data, Int32& position, MergeCacheContext context)\r\n at PX.Data.SQLTree.ProjectionForXmlReference.GetValue(PXDataRecord data, Int32& position, MergeCacheContext context)\r\n at PX.Data.SQLTree.ProjectionInitNew.GetValue(PXDataRecord data, Int32& position, MergeCacheContext context)\r\n at PX.Data.SQLTree.ProjectionInitNew.GetValue(PXDataRecord data, Int32& position, MergeCacheContext context)\r\n at PX.Data.SQLTree.SQLinqView.CreateResult(PXCachee] caches, PXDataRecord rec, Boolean hascount, Boolean& overrideSort, Boolean& extFilter)\r\n at PX.Data.PXView.GetResult(Objectt] parameters, PXFilterRoww] filters, Boolean reverseOrder, Int32 topCount, PXSearchColumnn] sorts, Boolean& overrideSort, Boolean& extFilter)\r\n at PX.Data.SQLTree.SQLinqView.GetResult(Objectt] parameters, PXFilterRoww] filters, Boolean reverseOrder, Int32 topCount, PXSearchColumnn] sorts, Boolean& overrideSort, Boolean& extFilter)\r\n at PX.Data.PXView.Select(Objectt] currents, Objectt] parameters, Objectt] searches, Stringg] sortcolumns, Booleann] descendings, PXFilterRoww] filters, Int32& startRow, Int32 maximumRows, Int32& totalRows, Stringg] sortAsImplicitColumns)\r\n at PX.Data.SQLTree.Async.AsyncSQLinqExecutor.ExecuteCollectionAsynccT](Query query, SQLinqBqlCommandInfo info, PXGraph graph, SQLinqExecutor linqExecutor, CancellationToken cancellationToken)\r\n at PX.Data.SQLTree.Async.AsyncSQLinqExecutor.ExecuteCollectionAsynccT](Query query, PXGraph graph)\r\n at PX.Data.SQLTree.Async.AsyncSQLinqExecutor.ExecuteCollectionAsynccT](QueryModel queryModel)\r\n at PX.Data.SQLTree.Async.AsyncSQLinqExecutor.<ExecuteCollectionAsync>d__2`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore`1.GetResult(Int16 token)\r\n at PX.Api.OData.Async.Formatter.Serialization.AsyncODataResourceSetSerializer.<WriteResourceSet>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at PX.Api.OData.Async.Formatter.Serialization.AsyncODataResourceSetSerializer.<WriteResourceSet>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at PX.Api.OData.Async.Formatter.Serialization.AsyncODataResourceSetSerializer.<WriteObjectAsync>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at PX.Api.OData.v4.Async.Helpers.AsyncODataOutputFormatterHelper.<WriteToStreamAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at PX.Api.OData.v4.Handlers.StreamingQueryContent.<SerializeToStreamAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at PX.Api.OData.v4.Handlers.DisableLinqFallbackContent.<SerializeToStreamAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at PX.Api.Compression.BaseCompressor.<Compress>d__4.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at PX.Api.Compression.CompressedContent.<SerializeToStreamAsync>d__4.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Owin.HttpMessageHandlerAdapter.<BufferResponseContentAsync>d__27.MoveNext()"
}
}
}

The following GET queries succeed without error (when I call each $expand individually), but when I call them both together (separated by a comma) then it fails with the above error.

GET Succeeds:

PX_Objects_SO_SOPickingWorksheet?$expand=SOPickerListEntryCollection($expand=InventoryItemByInventoryID)&$filter=WorksheetNbr eq '000001'

GET Succeeds:

PX_Objects_SO_SOPickingWorksheet?$expand=SOPickerListEntryCollection($expand=INToteByToteID)&$filter=WorksheetNbr eq '000001'

 

3 replies

Userlevel 7
Badge +11

Hi @sclassing ,

Did you try like below?

PX_Objects_SO_SOPickingWorksheet?$expand=SOPickerListEntryCollection($expand=InventoryItemByInventoryID),SOPickerListEntryCollection($expand=INToteByToteID)&$filter=WorksheetNbr eq '000001'

I just tried

SOPickerListEntryCollection($expand=InventoryItemByInventoryID),SOPickerListEntryCollection($expand=INToteByToteID)

And I get the same error message

{
"error": {
"code": "",
"message": "An error has occurred.",
"innererror": {
"message": "Index was outside the bounds of the array.",
"type": "System.IndexOutOfRangeException",
"stacktrace": " at PX.Data.PXXmlDataRecord.GetBoolean(Int32 i)\r\n at PX.Data.SQLTree.ProjectionConst.GetValue(PXDataRecord data, Int32& position, MergeCacheContext context)\r\n at PX.Data.SQLTree.ProjectionInitNew.GetValue(PXDataRecord data, Int32& position, MergeCacheContext context)\r\n at PX.Data.SQLTree.ProjectionInitNew.GetValue(PXDataRecord data, Int32& position, MergeCacheContext context)\r\n at PX.Data.SQLTree.ProjectionForXmlReference.GetValue(PXDataRecord data, Int32& position, MergeCacheContext context)\r\n at PX.Data.SQLTree.ProjectionInitNew.GetValue(PXDataRecord data, Int32& position, MergeCacheContext context)\r\n at PX.Data.SQLTree.ProjectionInitNew.GetValue(PXDataRecord data, Int32& position, MergeCacheContext context)\r\n at PX.Data.SQLTree.SQLinqView.CreateResult(PXCache[] caches, PXDataRecord rec, Boolean hascount, Boolean& overrideSort, Boolean& extFilter)\r\n at PX.Data.PXView.GetResult(Object[] parameters, PXFilterRow[] filters, Boolean reverseOrder, Int32 topCount, PXSearchColumn[] sorts, Boolean& overrideSort, Boolean& extFilter)\r\n at PX.Data.SQLTree.SQLinqView.GetResult(Object[] parameters, PXFilterRow[] filters, Boolean reverseOrder, Int32 topCount, PXSearchColumn[] sorts, Boolean& overrideSort, Boolean& extFilter)\r\n at PX.Data.PXView.Select(Object[] currents, Object[] parameters, Object[] searches, String[] sortcolumns, Boolean[] descendings, PXFilterRow[] filters, Int32& startRow, Int32 maximumRows, Int32& totalRows, String[] sortAsImplicitColumns)\r\n at PX.Data.SQLTree.Async.AsyncSQLinqExecutor.ExecuteCollectionAsync[T](Query query, SQLinqBqlCommandInfo info, PXGraph graph, SQLinqExecutor linqExecutor, CancellationToken cancellationToken)\r\n at PX.Data.SQLTree.Async.AsyncSQLinqExecutor.ExecuteCollectionAsync[T](Query query, PXGraph graph)\r\n at PX.Data.SQLTree.Async.AsyncSQLinqExecutor.ExecuteCollectionAsync[T](QueryModel queryModel)\r\n at PX.Data.SQLTree.Async.AsyncSQLinqExecutor.<ExecuteCollectionAsync>d__2`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore`1.GetResult(Int16 token)\r\n at PX.Api.OData.Async.Formatter.Serialization.AsyncODataResourceSetSerializer.<WriteResourceSet>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at PX.Api.OData.Async.Formatter.Serialization.AsyncODataResourceSetSerializer.<WriteResourceSet>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at PX.Api.OData.Async.Formatter.Serialization.AsyncODataResourceSetSerializer.<WriteObjectAsync>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at PX.Api.OData.v4.Async.Helpers.AsyncODataOutputFormatterHelper.<WriteToStreamAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at PX.Api.OData.v4.Handlers.StreamingQueryContent.<SerializeToStreamAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at PX.Api.OData.v4.Handlers.DisableLinqFallbackContent.<SerializeToStreamAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at PX.Api.Compression.BaseCompressor.<Compress>d__4.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at PX.Api.Compression.CompressedContent.<SerializeToStreamAsync>d__4.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Owin.HttpMessageHandlerAdapter.<BufferResponseContentAsync>d__27.MoveNext()"
}
}
}

 

Userlevel 7
Badge +5

@sclassing It seems like it’s a bug in the product. Should be fixed in 24r2

Reply