Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

error: Error: unknown format "int64" is used in schema #1879

Open
vkutepov opened this issue Dec 26, 2020 · 3 comments
Open

error: Error: unknown format "int64" is used in schema #1879

vkutepov opened this issue Dec 26, 2020 · 3 comments
Assignees

Comments

@vkutepov
Copy link

vkutepov commented Dec 26, 2020

Describe the bug
The following error is displayed:

   at Object.format [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:68605)
   at Object.at [as validate] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:33112)
   at Object.properties [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:85456)
   at Object.at [as validate] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:33112)
   at Object.$ref [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:56033)
   at Object.at [as validate] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:31656)
   at Object.properties [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:85456)
   at at (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:33112)
   at ya.P (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:35247)
   at ya.zr (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:21663)

This is an error in AJV v6
the guys from stoplightio encountered the same problem and solved it
stoplightio/spectral#187 (comment)

I wanted to know if it is possible to add to the dredd a flag that will not validate the scheme, and will only check the response code "--validate-schema" ?
Just like in this library ajv-cli
https://github.com/ajv-validator/ajv-cli#options-1

I can't use dredd because of this bug.

To Reproduce
Use this in your swagger spec:

    "serviceCategory": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "format": "int64"
        },
        "name": {
          "type": "string"
        },
        "long_name": {
          "type": "string"
        },
        "parent_id": {
          "type": "integer",
          "format": "int64"
        },
        "type_id": {
          "type": "integer",
          "format": "int64"
        }
      }
    }

    "GetCategoryByIDResponse": {
      "type": "object",
      "properties": {
        "result": {
          "$ref": "#/definitions/serviceCategory"
        }
      }
    }

Expected behavior
No error should be generated or displayed.

What's your dredd --version output?

dredd v13.1.0 (Darwin 19.6.0; x64)

Does dredd --loglevel=debug uncover something?

2020-12-26T09:39:04.381Z - debug: Running 'beforeEach' hooks
2020-12-26T09:39:04.381Z - debug: Running 'before' hooks
2020-12-26T09:39:04.381Z - debug: Emitting to reporters: test start
2020-12-26T09:39:04.382Z - debug: Performing HTTP request to the server under test: POST http://service.stg.o3.com/category/by-id
2020-12-26T09:39:05.008Z - debug: Handling HTTP response from the server under test
2020-12-26T09:39:05.009Z - debug: Running 'beforeEachValidation' hooks
2020-12-26T09:39:05.009Z - debug: Running 'beforeValidation' hooks
2020-12-26T09:39:05.009Z - debug: Validating HTTP transaction by Gavel.js
2020-12-26T09:39:05.082Z - debug: Gavel.js validation errored: Error: unknown format "int64" is used in schema at path "#/definitions/serviceCategory/properties/id"
    at Object.format [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:68605)
    at Object.at [as validate] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:33112)
    at Object.properties [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:85456)
    at Object.at [as validate] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:33112)
    at Object.$ref [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:56033)
    at Object.at [as validate] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:31656)
    at Object.properties [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:85456)
    at at (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:33112)
    at ya.P (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:35247)
    at ya.zr (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:21663)
2020-12-26T09:39:05.083Z - debug: Emitting to reporters: test error
error: Error: unknown format "int64" is used in schema at path "#/definitions/serviceCategory/properties/id"
    at Object.format [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:68605)
    at Object.at [as validate] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:33112)
    at Object.properties [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:85456)
    at Object.at [as validate] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:33112)
    at Object.$ref [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:56033)
    at Object.at [as validate] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:31656)
    at Object.properties [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:85456)
    at at (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:33112)
    at ya.P (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:35247)
    at ya.zr (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:21663)
error: POST (200) /category/by-id duration: 702ms
2020-12-26T09:39:05.083Z - debug: Running 'afterEach' hooks
2020-12-26T09:39:05.083Z - debug: Running 'after' hooks
2020-12-26T09:39:05.083Z - debug: Evaluating results of transaction execution #41: Service > /category/by-id > GetCategoryByID > 200 > application/json
2020-12-26T09:39:05.084Z - debug: No emission of test data to reporters Error: unknown format "int64" is used in schema at path "#/definitions/serviceCategory/properties/id"
    at Object.format [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:68605)
    at Object.at [as validate] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:33112)
    at Object.properties [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:85456)
    at Object.at [as validate] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:33112)
    at Object.$ref [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:56033)
    at Object.at [as validate] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:31656)
    at Object.properties [as code] (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:85456)
    at at (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:33112)
    at ya.P (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:35247)
    at ya.zr (/usr/local/lib/node_modules/dredd/node_modules/gavel/build/index.js:3:21663) status=fail, title=POST (200) /commercial-category/by-id, message=, filename=/Users/vsdk/dredd/swagger.json, apiName=internal/app/catalog_admin/endpoint/messages.proto, resourceGroupName=Service, resourceName=/category/by-id, actionName=GetCategoryByID, exampleName=200 > application/json, startedAt=1608975544381, errors=[], start=Sat Dec 26 2020 12:39:04 GMT+0300 (Москва, стандартное время), end=Sat Dec 26 2020 12:39:05 GMT+0300 (Москва, стандартное время), duration=702, statusCode=200, server=nginx/1.19.1, date=Sat, 26 Dec 2020 09:39:04 GMT, content-type=application/json; charset=utf-8, content-length=128, connection=close, x-o3-trace-id=8ea48238de7ce25, bodyEncoding=utf-8, body={"result":{"id":14594945,"name":"CAT","long_name":"cat","parent_id":348394,"type_id":3}}
, Content-Type=application/json, body={
  "result": {
    "id": -100000000,
    "name": "",
    "long_name": "",
    "parent_id": -100000000,
    "type_id": -100000000
  }
}, statusCode=200, bodySchema={"allOf":[{"$ref":"#/definitions/GetCategoryByIDResponse"}],"definitions":{"GetCategoryByIDResponse":{"type":"object","properties":{"result":{"$ref":"#/definitions/serviceCategory"}}},"serviceCategory":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"long_name":{"type":"string"},"parent_id":{"type":"integer","format":"int64"},"type_id":{"type":"integer","format":"int64"}}}}}, method=POST, uri=/category/by-id, Content-Type=application/json, Accept=application/json, User-Agent=Dredd/13.1.0 (Darwin 19.6.0; x64), body={
  "category_id": "14594945"
}, valid=undefined, 
@argos83
Copy link

argos83 commented Jan 14, 2021

We found the same issue with the swagger custom format "byte" (dredd v14.0.0 )

Error: unknown format "byte" is used in schema at path "#/properties/content"
    at Object.format [as code] (/..../node_modules/gavel/build/index.js:3:68605)
    at Object.at [as validate] (/..../node_modules/gavel/build/index.js:3:33112)
    at Object.properties [as code] (/..../node_modules/gavel/build/index.js:3:85456)

It seems swagger custom formats (extensions to json-schema) got somehow misconfigured when bumping AJV in gavel.
I'm not sure if this is an issue in Gavel, or the way Dredd uses Gavel. Since both projects are ApiaryIO's I thought it was ok to report it here.

I disagree with the proposed solution of having a flag to skip validation, I would prefer these formats to be supported again.

@abtris
Copy link
Contributor

abtris commented Feb 3, 2021

@artem-zakharchenko do you know if we support this custom data format in schema validation using Gavel?

@kylef
Copy link
Member

kylef commented Feb 3, 2021

I think this is pretty much the same as #1719 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants