[
https://issues.apache.org/jira/browse/THRIFT-5761?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jens Geyer resolved THRIFT-5761.
--------------------------------
Fix Version/s: 0.21.0
Resolution: Fixed
> Lib/json tests fail
> -------------------
>
> Key: THRIFT-5761
> URL: https://issues.apache.org/jira/browse/THRIFT-5761
> Project: Thrift
> Issue Type: Bug
> Components: JSON - Library
> Reporter: Thomas Bruggink
> Assignee: Thomas Bruggink
> Priority: Minor
> Fix For: 0.21.0
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> Running `ant validate-generated-json` fails with the following error:
> {code:java}
> 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
> {code}
> 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:
> {code:json}
> "constants": [
> {
> "name": "myNumberz",
> "typeId": "enum",
> "type": {
> "typeId": "enum",
> "class": "Numberz"
> },
> "value": 1
> }
> ],
> {code}
> but the expected output of the test is:
> {code:json}
> "constants": [
> {
> "name": "myNumberz",
> "typeId": "enum",
> "class": "Numberz",
> "value": 1
> }
> ],
> {code}
> assuming the original compiler is right the test should be updated.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)