Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5761

Lib/json tests fail

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 0.21.0
    • JSON - Library
    • None

    Description

      Running `ant validate-generated-json` fails with the following error:

      validate-generated-json:
           [java] --- BEGIN /thrift/src/lib/json/test/build/gen-json/ThriftTest.json---
           [java] validation: FAILURE
           [java] [ {
           [java]   "level" : "error",
           [java]   "schema" : {
           [java]     "loadingURI" : "file:/thrift/src/lib/json/schema.json#",
           [java]     "pointer" : "/definitions/constant"
           [java]   },
           [java]   "instance" : {
           [java]     "pointer" : "/constants/0"
           [java]   },
           [java]   "domain" : "validation",
           [java]   "keyword" : "allOf",
           [java]   "message" : "instance failed to match all required schemas (matched only 2 out of 3)",
           [java]   "matched" : 2,
           [java]   "nrSchemas" : 3,
           [java]   "reports" : {
           [java]     "/definitions/constant/allOf/0" : [ ],
           [java]     "/definitions/constant/allOf/1" : [ {
           [java]       "level" : "error",
           [java]       "schema" : {
           [java]         "loadingURI" : "file:/thrift/src/lib/json/schema.json#",
           [java]         "pointer" : "/definitions/type-desc"
           [java]       },
           [java]       "instance" : {
           [java]         "pointer" : "/constants/0"
           [java]       },
           [java]       "domain" : "validation",
           [java]       "keyword" : "allOf",
           [java]       "message" : "instance failed to match all required schemas (matched only 1 out of 2)",
           [java]       "matched" : 1,
           [java]       "nrSchemas" : 2,
           [java]       "reports" : {
           [java]         "/definitions/type-desc/allOf/0" : [ ],
           [java]         "/definitions/type-desc/allOf/1" : [ {
           [java]           "level" : "error",
           [java]           "schema" : {
           [java]             "loadingURI" : "file:/thrift/src/lib/json/schema.json#",
           [java]             "pointer" : "/definitions/type-desc/allOf/1"
           [java]           },
           [java]           "instance" : {
           [java]             "pointer" : "/constants/0"
           [java]           },
           [java]           "domain" : "validation",
           [java]           "keyword" : "oneOf",
           [java]           "message" : "instance failed to match exactly one schema (matched 0 out of 4)",
           [java]           "matched" : 0,
           [java]           "nrSchemas" : 4,
           [java]           "reports" : {
           [java]             "/definitions/type-desc/allOf/1/oneOf/0" : [ {
           [java]               "level" : "error",
           [java]               "schema" : {
           [java]                 "loadingURI" : "file:/thrift/src/lib/json/schema.json#",
           [java]                 "pointer" : "/definitions/base-type/properties/typeId"
           [java]               },
           [java]               "instance" : {
           [java]                 "pointer" : "/constants/0/typeId"
           [java]               },
           [java]               "domain" : "validation",
           [java]               "keyword" : "enum",
           [java]               "message" : "instance value (\"enum\") not found in enum (possible values: [\"void\",\"string\",\"bool\",\"byte\",\"i8\",\"i16\",\"i32\",\"i64\",\"double\",\"binary\",\"uuid\"])",
           [java]               "value" : "enum",
           [java]               "enum" : [ "void", "string", "bool", "byte", "i8", "i16", "i32", "i64", "double", "binary", "uuid" ]
           [java]             } ],
           [java]             "/definitions/type-desc/allOf/1/oneOf/1" : [ {
           [java]               "level" : "error",
           [java]               "schema" : {
           [java]                 "loadingURI" : "file:/thrift/src/lib/json/schema.json#",
           [java]                 "pointer" : "/definitions/list-type"
           [java]               },
           [java]               "instance" : {
           [java]                 "pointer" : "/constants/0"
           [java]               },
           [java]               "domain" : "validation",
           [java]               "keyword" : "required",
           [java]               "message" : "object has missing required properties ([\"elemTypeId\"])",
           [java]               "required" : [ "elemTypeId", "typeId" ],
           [java]               "missing" : [ "elemTypeId" ]
           [java]             }, {
           [java]               "level" : "error",
           [java]               "schema" : {
           [java]                 "loadingURI" : "file:/thrift/src/lib/json/schema.json#",
           [java]                 "pointer" : "/definitions/list-type/properties/typeId"
           [java]               },
           [java]               "instance" : {
           [java]                 "pointer" : "/constants/0/typeId"
           [java]               },
           [java]               "domain" : "validation",
           [java]               "keyword" : "enum",
           [java]               "message" : "instance value (\"enum\") not found in enum (possible values: [\"list\",\"set\"])",
           [java]               "value" : "enum",
           [java]               "enum" : [ "list", "set" ]
           [java]             } ],
           [java]             "/definitions/type-desc/allOf/1/oneOf/2" : [ {
           [java]               "level" : "error",
           [java]               "schema" : {
           [java]                 "loadingURI" : "file:/thrift/src/lib/json/schema.json#",
           [java]                 "pointer" : "/definitions/map-type"
           [java]               },
           [java]               "instance" : {
           [java]                 "pointer" : "/constants/0"
           [java]               },
           [java]               "domain" : "validation",
           [java]               "keyword" : "required",
           [java]               "message" : "object has missing required properties ([\"keyTypeId\",\"valueTypeId\"])",
           [java]               "required" : [ "keyTypeId", "typeId", "valueTypeId" ],
           [java]               "missing" : [ "keyTypeId", "valueTypeId" ]
           [java]             }, {
           [java]               "level" : "error",
           [java]               "schema" : {
           [java]                 "loadingURI" : "file:/thrift/src/lib/json/schema.json#",
           [java]                 "pointer" : "/definitions/map-type/properties/typeId"
           [java]               },
           [java]               "instance" : {
           [java]                 "pointer" : "/constants/0/typeId"
           [java]               },
           [java]               "domain" : "validation",
           [java]               "keyword" : "enum",
           [java]               "message" : "instance value (\"enum\") not found in enum (possible values: [\"map\"])",
           [java]               "value" : "enum",
           [java]               "enum" : [ "map" ]
           [java]             } ],
           [java]             "/definitions/type-desc/allOf/1/oneOf/3" : [ {
           [java]               "level" : "error",
           [java]               "schema" : {
           [java]                 "loadingURI" : "file:/thrift/src/lib/json/schema.json#",
           [java]                 "pointer" : "/definitions/struct-type"
           [java]               },
           [java]               "instance" : {
           [java]                 "pointer" : "/constants/0"
           [java]               },
           [java]               "domain" : "validation",
           [java]               "keyword" : "required",
           [java]               "message" : "object has missing required properties ([\"class\"])",
           [java]               "required" : [ "class", "typeId" ],
           [java]               "missing" : [ "class" ]
           [java]             } ]
           [java]           }
           [java]         } ]
           [java]       }
           [java]     } ],
           [java]     "/definitions/constant/allOf/2" : [ ]
           [java]   }
           [java] } ]
           [java] --- END /thrift/src/lib/json/test/build/gen-json/ThriftTest.json---
      
      BUILD FAILED
      /thrift/src/lib/json/test/build.xml:94: The following error occurred while executing this line:
      /thrift/src/lib/json/test/build.xml:137: Java returned: 100
      

      The issues seems to come from the recent changes to move `enum` into the `struct`. Previously the `constant` section was only tested for `enum` being ` number` but now that it has been moved to a struct the `#/definitions/type-desc` seems to fail.
      I think this was always broken just skipped during testing.

      The JSON output is:

        "constants": [
          {
            "name": "myNumberz",
            "typeId": "enum",
            "type": {
              "typeId": "enum",
              "class": "Numberz"
            },
            "value": 1
          }
        ],
      

      but the expected output of the test is:

        "constants": [
          {
            "name": "myNumberz",
            "typeId": "enum",
            "class": "Numberz",
            "value": 1
          }
        ],
      

      assuming the original compiler is right the test should be updated.

      Attachments

        Issue Links

          Activity

            People

              thomasbruggink Thomas Bruggink
              thomasbruggink Thomas Bruggink
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m