Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Retrieving JSON arrays via fields selector is broken in Ditto 3.5.1 #1888

Closed
AkshayKumarCB opened this issue Feb 2, 2024 · 3 comments · Fixed by #1890
Closed

Retrieving JSON arrays via fields selector is broken in Ditto 3.5.1 #1888

AkshayKumarCB opened this issue Feb 2, 2024 · 3 comments · Fixed by #1890
Assignees
Labels
Milestone

Comments

@AkshayKumarCB
Copy link

AkshayKumarCB commented Feb 2, 2024

The GET /api/2/search/things API is currently broken on the release Ditto 3.5.1 when we attempt to fetch an array property.
A sample scenario is given below.

Sample data stored in Ditto:

{
  "thingId": "sample.eclipse.com:test_1",
  "policyId": "sample.eclipse.com:policy-default",
  "attributes": {
    "a": "b"
  },
  "features": {
    "values": {
      "properties": {
        "a": [
          1,
          2,
          3
        ]
      }
    }
  }
}

API query to fetch only the array 'a' from the Ditto thing:
/api/2/search/things?namespaces=sample.eclipse.com&fields=features/values/properties/a

Response on Ditto 3.4.4: (Returns array with values for "a")
{"items":[{"features":{"values":{"properties":{"a":[1,2,3]}}}}],"nextPageOffset":-1}

Response on Ditto 3.5.1: (Returns an empty array for "a")
{"items":[{"features": { "values": { "properties": { "a": [] }}}}],"nextPageOffset": -1}

However, if we were to update the fields query parameter in the request from features/values/properties/a to features/values/properties, we get the correct response - similar to what was observed in 3.4.4.

Looks like we have a bug for search/things API for arrays in 3.5.1 that needs to be fixed.

Reproducibility rate: 100% (5/5)

@AkshayKumarCB AkshayKumarCB changed the title GET search/things API is currently broken for Ditto 3.5.x GET search/things API is currently broken for Ditto 3.5.1 Feb 2, 2024
@AkshayKumarCB AkshayKumarCB changed the title GET search/things API is currently broken for Ditto 3.5.1 GET /search/things API is currently broken for Ditto 3.5.1 Feb 2, 2024
@AkshayKumarCB
Copy link
Author

Looks like the same behavior is also observed for /api/2/things API:

Request: /api/2/things/sample.eclipse.com:test_1?fields=features/values/properties/a
Response: {"features":{"values":{"properties":{"a":[]}}}}

Request: /api/2/things/sample.eclipse.com:test_1?fields=features/values/properties
Respnose: {"features":{"values":{"properties":{"a":[1,2,3]}}}}

@AkshayKumarCB AkshayKumarCB changed the title GET /search/things API is currently broken for Ditto 3.5.1 GET /search/things API is currently broken for Ditto 3.5.1 for array properties Feb 2, 2024
@AkshayKumarCB AkshayKumarCB changed the title GET /search/things API is currently broken for Ditto 3.5.1 for array properties GET /search/things and /things APIs are currently broken for array properties in Ditto 3.5.1 Feb 2, 2024
@thjaeckle thjaeckle changed the title GET /search/things and /things APIs are currently broken for array properties in Ditto 3.5.1 Retrieving JSON arrays via fields selector is broken in Ditto 3.5.1 Feb 2, 2024
@thjaeckle thjaeckle added the bug label Feb 2, 2024
@thjaeckle thjaeckle added this to the 3.5.2 milestone Feb 2, 2024
@thjaeckle
Copy link
Member

Thanks a lot @AkshayKumarCB for the bugreport.
I will look into it - I remember having changed something around the field selection.

@thjaeckle
Copy link
Member

I assume this bug was introduced in PR #1860

@thjaeckle thjaeckle self-assigned this Feb 2, 2024
thjaeckle added a commit that referenced this issue Feb 4, 2024
…rays-in-fieldselectors

#1888 fix retrieving simple arrays via field selectors
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants