silverton-io / buz

Serverless multi-protocol + multi-destination event collection system.
https://buz.dev/
Apache License 2.0
186 stars 21 forks source link

Schema validation failing in new version which was functional in previous release #567

Closed sachingade20 closed 1 year ago

sachingade20 commented 1 year ago
{"level":"error","error":"jsonschema file:///app/health.json compilation failed: unsupported draft in https://schemas.XXXX.com/com.XXXX/buz/internal/meta/v1.0.json","time":"2023-05-08T13:41:37Z","message":"could not compile schema"}

[{"uuid":"00873d6d-1012-4268-b754-f0d523e3ba93","timestamp":"2023-05-08T13:41:37.247386871Z","buzTimestamp":"2023-05-08T13:41:37.247386871Z","buzVersion":"v0.17.0","buzName":"tw-buz","buzEnv":"prod","protocol":"webhook","schema":"health.json","vendor":"com.XXXX","namespace":"buz.hook.health","version":"1.0","isValid":false,"validationError":{"errorType":"invalid schema","errorResolution":"ensure schema is properly formatted"},"contexts":{"io.silverton/buz/internal/contexts/httpHeaders/v1.0.json":{"Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Content-Length":"30","Content-Type":"application/json","Postman-Token":"584fb307-8907-47f7-8883-dcdb55382cc6","User-Agent":"PostmanRuntime/7.32.2","X-Amzn-Trace-Id":"Root=1-6458fc11-0e0814ba1ededa9c3a6dc9df","X-Forwarded-For":"49.248.66.146","X-Forwarded-Port":"443","X-Forwarded-Proto":"https"}},"payload":{"requester":"datadog"}}]

{"level":"error","error":"jsonschema file:///app/health.json compilation failed: unsupported draft in https://schemas.XXXXX.com/com.trailways/buz/internal/meta/v1.0.json","time":"2023-05-08T13:42:16Z","message":"could not compile schema"}

@jakthom after updating version to latest , our schema failing to validate . Webhook was working in 14.X version its started failing in this version

below is our schema

{
    "$schema": "https://schemas.XXXX.com/com.XXXX/buz/internal/meta/v1.0.json",
    "$id": "com.XXXX/buz/health.json",
    "title": "com.XXX/buz/health.json",
    "description": "A webhook containing health check",
    "owner": {
        "org": "XXXXX",
        "team": "dev",
        "individual": "sgade"
    },
    "self": {
        "vendor": "com.XXXXX",
        "namespace": "buz.hook.health",
        "version": "1.0"
    },
    "type": "object",
    "properties": {
        "requester": {
            "type": "string"
        }
    },
    "required": [
        "requester"
    ],
    "additionalProperties": true
}
jakthom commented 1 year ago

@sachingade20 the metaschema located at https://schemas.XXXX.com/com.XXXX/buz/internal/meta/v1.0.json will need to reference https://json-schema.org/draft/2020-12/schema instead of a metaschema.

See https://github.com/silverton-io/buz/blob/main/schemas/io.silverton/buz/internal/meta/v1.0.json#L2 for the desired value.

The tl;dr is the previous schema validator did not properly recurse schemas. The new one does.

sachingade20 commented 1 year ago

thanks @jakthom