error when trying to display 1 iteration of a querry thats its empty

a!queryEntity(
  entity: cons!AS_DataStore_Ratings_Pointer,
  query: a!query(
    aggregation: a!queryAggregation(
      aggregationColumns: {
        a!queryAggregationColumn(
          field: "productId",
          isGrouping: true
        ),
        a!queryAggregationColumn(
          field: "rating",
          alias: "rating_average",
          aggregationFunction: "AVG"
        )
      }
    ),
    logicalExpression: a!queryLogicalExpression(
      operator: "AND",
      filters: {
        a!queryFilter(
          field: "productId",
          operator: "=",
          value: ri!productId
        )
      },
      ignoreFiltersWithEmptyValues: true
    ),
    pagingInfo: a!pagingInfo(
      startIndex: 1,
      batchSize: 50
    )
  ),
  fetchTotalCount: false
).data

Hi!

so i have this query which return the average of a value from an ID, but not all items  have rating and when i. use it in a foreach i get this error:

Interface Definition: Expression evaluation error at function a!forEach [line 63]: Error in a!forEach() expression during iteration 3: Expression evaluation error: Invalid index: Cannot index property 'average_rating' of type String into type List of Variant

it says during iteration 3 because its the first time there is no rating on a specific item. Any help?

  Discussion posts and replies are publicly visible