Bug (or incomplete report) in ValidateJson()

Hi everyone.

I’m playing with new extension ValidateJson()

I found this error (or incomplete report):

This code:

<cfset schema = '{
   "$schema": "http://json-schema.org/draft-07/schema",
   "title": "Patient",
   "description": "Patient of catalogue",
   "type": "object",
   "properties": {
       "name": {
           "type": "string"
       },

       "genre": {
           "type": "object",
           "properties": {
               "code": {
                   "type": "string"
               },
               "name": {
                   "type": "string"
               }
           }
       }
   },

   "required": [
       "name",
       "doctor"
   ]
}'>

<cfset json = '{
   "name": 11,
   "genre": {
       "code": 3
   }
}'>

<cfset result = ValidateJson(json, schema, false)>

<cfdump var="#result#">

The validation shows only one error:

validation-only-required

Whereas the Validator Json Schema shows three errors:
(https://www.jsonschemavalidator.net/)

Any hint?
Many thanks

OS: Windows 10
Lucee Version: 5.3.7.47

@Roberto_Marzialetti, Yes, it has happened as you said.
It throws an error like missing required properties only. But, it didn’t show other errors.
If we solve the first error means, at that time it showing another two errors
instance type does not match any allowed primitive type. So, I think it is a bug.
Please file a bug.

thanks @cfmitrah,

i’ll file the bug asap

another point, please:

  • can i have the list of all error messages that are shown in “message” key in error structure? i don’t find the extension in github repository.

many thanks.

I created issue:
Lucee Development - Issues - Lucee

yeah, the extension repo disappeared. it was a funded extension. don’t know what happened

@micstriit how should Roberto submit improvements?

Hello

I am using ValidateJson()

During development we experienced no issue except for a bug* described above.

This is my schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "User",
    "description": "User",
    "type": "object",
    "properties": {
        "id": {
            "description": "UserId",
            "type": "string",
            "minLength": 0
        },
        "name": {
            "description": "User name",
            "type": "string",
            "minLength": 2
        },
        "role": {
            "$ref": "http://services.smartvillage.cc:8199/api/schema/roleSchema.json"
        },
        "account": {
            "$ref": "http://services.smartvillage.cc:8199//api/schema/accountSchema.json"
        }
    }
}

In testing (with the same Lucee version, installed through CommandBox) we have this error:

I try to remove the “$ref” keys and we obtain this error:

com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: com/github/fge/jsonschema/keyword/digest/draftv4/RequiredDigester$1

StackTrace at the bottom

Any idea?

Many thanks

lucee.runtime.exp.NativeException: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: com/github/fge/jsonschema/keyword/digest/draftv4/RequiredDigester$1 at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2256) at com.google.common.cache.LocalCache.get(LocalCache.java:3990) at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3994) at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4878) at com.github.fge.jsonschema.processing.CachingProcessor.process(CachingProcessor.java:91) at com.github.fge.jsonschema.processors.validation.ValidationProcessor.process(ValidationProcessor.java:77) at com.github.fge.jsonschema.processors.validation.ValidationProcessor.process(ValidationProcessor.java:46) at com.github.fge.jsonschema.processing.ProcessingResult.of(ProcessingResult.java:79) at com.github.fge.jsonschema.main.JsonSchema.doValidate(JsonSchema.java:69) at com.github.fge.jsonschema.main.JsonSchema.validate(JsonSchema.java:93) at org.lucee.extension.json.function.ValidateJson.call(ValidateJson.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at lucee.runtime.reflection.pairs.MethodInstance.invoke(MethodInstance.java:56) at lucee.runtime.reflection.Reflector.callStaticMethod(Reflector.java:951) at lucee.runtime.functions.BIFProxy.invoke(BIFProxy.java:41) at lucee.runtime.functions.FunctionHandlerPool.invoke(FunctionHandlerPool.java:40) at com.smartvillage.core.util.jsonvalidator.jsonvalidator_cfc$cf$2u.udfCall(/com/smartvillage/core/util/JsonValidator/JsonValidator.cfc:18) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:207) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:681) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:568) at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1917) at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:864) at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1729) at com.smartvillage.api.controller.user_cfc$cf.udfCall(/com/smartvillage/api/controller/User.cfc:63) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:207) at lucee.runtime.type.scope.ArgumentImpl.callWithNamedValues(ArgumentImpl.java:494) at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:864) at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1729) at system.resthandler_cfc$cf$28.udfCall1(/coldbox/system/RestHandler.cfc:64) at system.resthandler_cfc$cf$28.udfCall(/coldbox/system/RestHandler.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:207) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:681) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:568) at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1917) at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:864) at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1729) at system.web.controller_cfc$cf.udfCall3(/coldbox/system/web/Controller.cfc:923) at system.web.controller_cfc$cf.udfCall(/coldbox/system/web/Controller.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:207) at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:792) at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:864) at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1729) at system.web.controller_cfc$cf.udfCall3(/coldbox/system/web/Controller.cfc:646) at system.web.controller_cfc$cf.udfCall(/coldbox/system/web/Controller.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:207) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:681) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:568) at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1917) at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:864) at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1729) at system.bootstrap_cfc$cf.udfCall1(/coldbox/system/Bootstrap.cfc:268) at system.bootstrap_cfc$cf.udfCall(/coldbox/system/Bootstrap.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:217) at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:779) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:785) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1710) at system.bootstrap_cfc$cf.udfCall1(/coldbox/system/Bootstrap.cfc:502) at system.bootstrap_cfc$cf.udfCall(/coldbox/system/Bootstrap.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:217) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:680) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:568) at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1898) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:785) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1710) at api.application_cfc$cf$2o.udfCall(/api/Application.cfc:35) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:217) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:680) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:568) at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1898) at lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:436) at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:132) at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:42) at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2416) at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2406) at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2381) at lucee.runtime.engine.Request.exe(Request.java:43) at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1170) at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1116) at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97) at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51) at javax.servlet.http.HttpServlet.service(HttpServlet.java:590) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.cfmlprojects.regexpathinfofilter.RegexPathInfoFilter.doFilter(RegexPathInfoFilter.java:47) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:415) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at runwar.Server$1.handleRequest(Server.java:531) at io.undertow.servlet.handlers.SendErrorPageHandler.handleRequest(SendErrorPageHandler.java:52) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:387) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:841) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.lang.Thread.run(Thread.java:748) Caused by: com.google.common.util.concurrent.ExecutionError: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: com/github/fge/jsonschema/keyword/digest/draftv4/RequiredDigester$1 … 141 more Caused by: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: com/github/fge/jsonschema/keyword/digest/draftv4/RequiredDigester$1 at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2256) at com.google.common.cache.LocalCache.get(LocalCache.java:3990) at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3994) at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4878) at com.github.fge.jsonschema.processing.CachingProcessor.process(CachingProcessor.java:91) at com.github.fge.jsonschema.processors.validation.ValidationChain.process(ValidationChain.java:105) at com.github.fge.jsonschema.processors.validation.ValidationChain.process(ValidationChain.java:52) at com.github.fge.jsonschema.processing.ProcessorMap$Mapper.process(ProcessorMap.java:169) at com.github.fge.jsonschema.processing.ProcessingResult.of(ProcessingResult.java:79) at com.github.fge.jsonschema.processing.CachingProcessor$1.load(CachingProcessor.java:110) at com.github.fge.jsonschema.processing.CachingProcessor$1.load(CachingProcessor.java:102) at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3589) at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2374) at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2337) at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2252) … 140 more Caused by: java.lang.NoClassDefFoundError: com/github/fge/jsonschema/keyword/digest/draftv4/RequiredDigester$1 at com.github.fge.jsonschema.keyword.digest.draftv4.RequiredDigester.digest(RequiredDigester.java:62) at com.github.fge.jsonschema.processors.digest.SchemaDigester.buildDigests(SchemaDigester.java:94) at com.github.fge.jsonschema.processors.digest.SchemaDigester.process(SchemaDigester.java:80) at com.github.fge.jsonschema.processors.digest.SchemaDigester.process(SchemaDigester.java:45) at com.github.fge.jsonschema.processing.ProcessorChain$ProcessorMerger.process(ProcessorChain.java:168) at com.github.fge.jsonschema.processing.ProcessorChain$ProcessorMerger.process(ProcessorChain.java:168) at com.github.fge.jsonschema.processing.ProcessingResult.of(ProcessingResult.java:79) at com.github.fge.jsonschema.processing.CachingProcessor$1.load(CachingProcessor.java:110) at com.github.fge.jsonschema.processing.CachingProcessor$1.load(CachingProcessor.java:102) at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3589) at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2374) at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2337) at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2252) … 154 more

Is there a public repo for the Validator?

Hi all,

Roberto’s schema from May 31 does also throw an error if you use

http://json-schema-validator.herokuapp.com/index.jsp

which is the online version of json-schema-validator

it stumbles over those services.smartvillage.cc:8199 URIs (“URI not normalized”).

What happens if you replace the values for “role” and “account” with the copy and pasted definitions (see below)? json-schema-validator then is happy about it. Maybe this works then
also with the Lucee JSON module?

– Chris

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "User",
  "description": "User",
  "type": "object",
  "properties": {
    "id": {
      "description": "UserId",
      "type": "string",
      "minLength": 0
    },
    "name": {
      "description": "User name",
      "type": "string",
      "minLength": 2
    },
    "role": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "title": "Role",
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "description": "RoleId",
          "type": "string",
          "minLength": 3
        },
        "name": {
          "description": "role name",
          "type": "string"
        }
      }
    },
    "account": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "title": "Account",
      "type": "object",
      "required": [
        "email",
        "pwd"
      ],
      "properties": {
        "id": {
          "description": "AccountId",
          "type": "integer",
          "minLength": 0
        },
        "email": {
          "description": "Email",
          "type": "string",
          "minLength": 2,
          "format": "email"
        },
        "pwd": {
          "description": "Password",
          "type": "string",
          "minLength": 8,
          "pattern": "^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,}$"
        }
      }
    }
  }
}