matkapi / postpy2

Postman collection runner library for python
Other
35 stars 15 forks source link

JSON body parsing issue with environment variable replacement #9

Open matprov opened 3 years ago

matprov commented 3 years ago

When we send a JSON body containing a serialized JSON object as a property value, format_object() causes two issues.

Sample json:

{
  "inputs": [
    {
      "data": "{\"features\": [{\"geometry\": {\"type\": \"Polygon\", \"coordinates\": []}}]}"
    }
]

First issue is related to .replace('{{', '{').replace('}}', '}') that replaced the "}}" with "}", which errors the parsing.

Second issue is the parsing that will be chosen in this case will be the one defined by isinstance(o, str) since it's a string, therefore not parsing the body properly, and will try to replace parts of the string with non-existing environment variables.