[SOLVED] Empty reference returned as object instead of array

I have…

  • [ ] Checked the logs and have uploaded a log file and provided a link because I found something suspicious there. Please do not post the log file in the topic because very often something important is missing.

I’m submitting a…

  • [X] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

Reference fields when empty are returned as an empty Object

Expected behavior

Until few days ago, if a reference was empty, an empty Array was returned

Environment

  • [ ] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [X] Cloud version

Version: [VERSION]

Browser:

  • [ ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:

I guess you mean

{
  "field": {
     "iv": []
   }
}

instead of

{
  "field": {}
}

?

Yes sorry, I should have added the example

How do you create the content? Because I think I have not made any change to it.

The content is created/edited from the cloud squidex client.
The empty references that we had and did not touch are fine, while the one we remove leaving the reference empty have a different behavior wrt. the ones not touched.

Unfortunately I have no way to show an example as the data not touched is in our chache. But I’m pretty sure it’s due to the fact that before the release, the behavior was as reported by you in the first comment.

Could be, but the API does not enforce it. If the field is not required an undefined value is fine. If you can I would just check for null.

So even if I fix it in the UI, there is no guarantee that it is always set.

I managed to extract an example:
Headers
X-Languages it
X-Unpublished true
X-Flatten true

previous behavior
{
“topContentBlock”: [
“2439612c-1ad4-493b-9f4a-10cfc248e90d”
],
“dataSecurity”: [],
}

current behavior
{
“topContentBlock”: [
“2439612c-1ad4-493b-9f4a-10cfc248e90d”
],
"dataSecurity": {},
}

Oh, it is for flatten. Okay, that could be a bug.

Can you give me your app name and a conrete query? Perhaps as PM?

Can you send me a sample query or the schema name?

Hi, I had another look. There is a bug, that it returns an empty object. But the correct behaviour would be to return “null” currently or not even include it in the response.

The X-Flatten only resolves the first value it can find. If there is no value, it cannot return something and the references-editor sets a value to null if no references are selected.

A null value should be fine

It is solved, but not deployed yet.