Subrequests breaks REST responses if the result contains any empty arrays

Created on 26 November 2019, about 5 years ago
Updated 18 December 2023, 12 months ago

I have a REST endpoint that returns an associative array that should be encoded as JSON.
I have the following test request:

GET {{base_url}}/{{sitepath}}/rest/mypath/mylocale/myquerytype/mysearchterm
Content-Type: application/json
Accept: application/json
Authorization: Basic myauthdata

With the subrequests module uninstalled I get the expected response:

{
  "name": {
    "language": "de",
    "text": "mysearchterm"
  },
  "recommendations": [],
  "found": true,
  "another_empty_array": []
}

After enabling subrequests (just drush en subrequests; drush cr) the response is garbled
at each point of the result where there should be an empty array:

{
  "name": {
    "language": "de",
    "text": "mysearchterm"
  },
  "recommendations": {
    "content": "[]",
    "headers": {
      "Content-Type": "application\/json; type="
    }
  },
  "found": true,
  "another_empty_array": {
    "content": "[]",
    "headers": {
      "Content-Type": "application\/json; type="
    }
  }
}

🐛 Bug report
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

🇩🇪Germany cspitzlay 🇩🇪🇪🇺

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024