SAP / open-ux-odata

Enable community collaboration to jointly promote and facilitate best in class framework and tooling capabilities when working with OData services.
Apache License 2.0
51 stars 12 forks source link

BUG - Expansion depth in odata v2 is only limited to two #546

Closed LombardsAI closed 1 year ago

LombardsAI commented 1 year ago

Related Feature

Description

When I'm using @sap-ux/fe-mockserver-core as a mock server for opa5 test. I use odata v2 request and want to expand a property for 3-layer deep. Only 2 layers are expanded, and the third level is ignored.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Send an odata v2 request with $expand parameter more than 2 layers
  2. See error: only 2 layers can be expanded.

Expected results

All the requested expansion structure can be returned as result

Actual results

Only 2 layers can be expanded.

Screenshots

Version/Components/Environment

Add any other context about the problem here OS:

Root Cause Analysis

Problem

https://github.com/SAP/open-ux-odata/blame/9f3cc504ae9caf4255316692de820ffbe4d3d49d/packages/fe-mockserver-core/src/request/odataRequest.ts#L241 That only the second level of expansion goes into the recursive method, the deeper level isignored

Fix

{describe the fix}

Why was it missed

{Some explanation why this issue might have been missed during normal development/testing cycle}

How can we avoid this

{if we don’t want to see this type of issues anymore what we should do to prevent}

nlunets commented 1 year ago

HI @LombardsAI would it be possible for you to provide a sample metadata / query where this could be reproduced easily ?

LombardsAI commented 1 year ago

Hi @nlunets, if you can follow this link: epd-specification/specmgmt/blob/main/app/ui-property/webapp/localService/metadataV2.xml to get the metadata file and use https://{{your_server}}/odata/v2/PropertyConfigureService/Property?$expand=attributeSetting/attributeFields/texts&$filter=displayId eq '{{mock-property-id}}' to reproduce the error(third level expand "texts" are not returned in the response

nlunets commented 1 year ago

@LombardsAI your mockdata (btw private URL), doesn't contain data for attributeFields, so as such no expansion is possible for the last level.

Even attributeSetting is completely auto generated based on the non-nullability of the field.

If you fill in mockdata you will see your data

LombardsAI commented 1 year ago

Hello @nlunets, I'm afraid the problem is that in this line of code https://github.com/SAP/open-ux-odata/blame/9f3cc504ae9caf4255316692de820ffbe4d3d49d/packages/fe-mockserver-core/src/request/odataRequest.ts#L241 the expand is split by "/", and in this line https://github.com/SAP/open-ux-odata/blame/9f3cc504ae9caf4255316692de820ffbe4d3d49d/packages/fe-mockserver-core/src/request/odataRequest.ts#L244 only the second element in the split array goes into the recursive method. You can ping Fang,David in teams and I can demo this to you by screen sharing.