openziti / ziti

The parent project for OpenZiti. Here you will find the executables for a fully zero trust, application embedded, programmable network @OpenZiti
https://openziti.io
Apache License 2.0
2.82k stars 159 forks source link

Schema mutilated on Config Type creation via CLI #257

Closed Russell-Allen closed 3 years ago

Russell-Allen commented 3 years ago

I attempted to create a Config Type with a valid schema as follows:

./ziti edge create config-type TEST02 "{  \"$id\": \"https://example.com/person.schema.json\",  \"$schema\": \"http://json-schema.org/draft-07/schema#\",  \"title\": \"Person\",  \"type\": \"object\",  \"properties\": {    \"firstName\": {      \"type\": \"string\",      \"description\": \"The person's first name.\"    },    \"lastName\": {      \"type\": \"string\",      \"description\": \"The person's last name.\"    },    \"age\": {      \"description\": \"Age in years which must be equal to or greater than zero.\",      \"type\": \"integer\",      \"minimum\": 0    }  }}"

The Config Type was created, but the schema is missing the $id property and has an empty string where the $schema key should be:

{
   "data": [
      {
         "_links": {
            "self": {
               "href": "./config-types/PaRK4rKbw"
            }
         },
         "createdAt": "2020-12-29T18:49:15.717Z",
         "id": "PaRK4rKbw",
         "tags": {},
         "updatedAt": "2020-12-29T18:49:15.717Z",
         "name": "TEST02",
         "schema": {
            "": "http://json-schema.org/draft-07/schema#",
            "properties": {
               "age": {
                  "description": "Age in years which must be equal to or greater than zero.",
                  "minimum": 0,
                  "type": "integer"
               },
               "firstName": {
                  "description": "The person's first name.",
                  "type": "string"
               },
               "lastName": {
                  "description": "The person's last name.",
                  "type": "string"
               }
            },
            "title": "Person",
            "type": "object"
         }
      }
   ],
   "meta": {
      "filterableFields": [
         "id",
         "createdAt",
         "updatedAt",
         "name",
         "schema"
      ],
      "pagination": {
         "limit": 10,
         "offset": 0,
         "totalCount": 1
      }
   }
}

I started down this path with the intent of testing that a Config Type's schema was validated against the Json Schema meta-schema. The above was a test to ensure I was 'doing it right' ... that my usage of the CLI was correct. After that I intended to test a bad schema, like this (note I tweaked the $id and $schema property values to be an invalid type.):

./ziti edge create config-type TEST03 "{  \"$id\": {},  \"$schema\": 1234,  \"title\": \"Person\",  \"type\": \"object\",  \"properties\": {    \"firstName\": {      \"type\": \"string\",      \"description\": \"The person's first name.\"    },    \"lastName\": {      \"type\": \"string\",      \"description\": \"The person's last name.\"    },    \"age\": {      \"description\": \"Age in years which must be equal to or greater than zero.\",      \"type\": \"integer\",      \"minimum\": 0    }  }}"

I was hoping for an error response, but this too was accepted and the resulting config type looks like:

{
   "data": [
      {
         "_links": {
            "self": {
               "href": "./config-types/LBgafDWbd"
            }
         },
         "createdAt": "2020-12-30T01:15:44.667Z",
         "id": "LBgafDWbd",
         "tags": {},
         "updatedAt": "2020-12-30T01:15:44.667Z",
         "name": "TEST03",
         "schema": {
            "": 1234,
            "properties": {
               "age": {
                  "description": "Age in years which must be equal to or greater than zero.",
                  "minimum": 0,
                  "type": "integer"
               },
               "firstName": {
                  "description": "The person's first name.",
                  "type": "string"
               },
               "lastName": {
                  "description": "The person's last name.",
                  "type": "string"
               }
            },
            "title": "Person",
            "type": "object"
         }
      }
   ],
   "meta": {
      "filterableFields": [
         "id",
         "createdAt",
         "updatedAt",
         "name",
         "schema"
      ],
      "pagination": {
         "limit": 10,
         "offset": 0,
         "totalCount": 1
      }
   }
}

Caution - I am learning my way around Ziti and the CLI. This may be a simple problem between the keyboard and chair. Don't dive too deep before ruling out the obvious. ;)

My local testing is against:

Version     : v0.18.0
GIT revision: d2c7bbfc6f6a
Build Date  : 2020-12-17 19:56:38
Runtime     : go1.15.6
plorenz commented 3 years ago

Seems likely to be shell replacement issue. Unable to reproduce with local testing against the API.