Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

set operator create nested JSON object when a key includes "." #4315

Closed
danielvillalbamota opened this issue Apr 18, 2023 · 1 comment
Closed
Labels
Milestone

Comments

@danielvillalbamota
Copy link
Collaborator

Bug description

  • Orion version: 3.8.1

When use $set operator in an UPDATE request if the value of an attribute is a JSON object with a key compounds by dots (".") the entity is UPDATED with the JSON object but nested in different subkeys split by the ".".

How to reproduce it
Steps to reproduce the behavior (as an example)

  1. Create an entity this way:
curl -iX POST 'http://localhost:1026/v2/entities' \
--header 'Fiware-Service: service' \
--header 'Fiware-ServicePath: /servicepath' \
--header 'X-Auth-Token: ...' \
--header 'Content-Type: application/json' \
--data '{
  "id": "dumps_3.2.0",
  "type": "Vertical"
}'
  1. Then update the entity
curl --location 'http://localhost:1026/v2/entities/dumps_3.2.0/attrs' \
--header 'Fiware-Service: service' \
--header 'Fiware-ServicePath: /servicepath' \
--header 'X-Auth-Token: ...' \
--header 'Content-Type: application/json' \
--data '{
  "upgrades": {
    "type": "Json",
    "value": {
      "$set": {
        "dumps_3.1.0": {
          "folder": "dumps",
          "version": "3.2.0",
          "path": "upgrades/3.1.0-to-3.2.0"
        }
      }
    }
  }
}'
  1. The entity loaded in the CB
{
    "id": "dumps_3.2.0",
    "type": "Vertical",
    "upgrades": {
        "type": "Json",
        "value": {
            "dumps_3": {
                "1": {
                    "0": {
                        "folder": "dumps",
                        "version": "3.2.0",
                        "path": "upgrades/3.1.0-to-3.2.0"
                    }
                }
            }
        },
        "metadata": {}
    }
}

Expected behavior
The entity is expected within the format which was sent.

@fgalan
Copy link
Member

fgalan commented May 8, 2023

Fixed by PR #4324

@fgalan fgalan closed this as completed May 8, 2023
@fgalan fgalan added this to the 3.9.0 milestone Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants