service-fabrik-broker icon indicating copy to clipboard operation
service-fabrik-broker copied to clipboard

'validate is not a function' error

Open dlapanik opened this issue 2 years ago • 1 comments

Describe the bug Getting error 'validate is not a function' when try to create service instance if for SFPlan definition JSON Schema draft-07 was used.

To Reproduce Steps to reproduce the behavior:

  1. Define SFPlan with "$schema": "http://json-schema.org/draft-07/schema#"
  schemas:
    service_instance:
      create:
        parameters:
          "$schema": "http://json-schema.org/draft-07/schema#"
          title: createServiceInstance
          type: object
          additionalProperties: false
          _show_form_view: true
          properties:
            backend:
              type: string
  1. try to create service instance

Expected behavior As soon as you are using https://ajv.js.org for JSON validation I expect that drafts 04, 06, 07, 2019-09 and 2020-12 are supported.

If by some reason you support only draft-04,-06 I expect do not see runtime error but appropriate message (better during applying SFPlan and not when somebody tries to create service instance)

Additional context Error raised from line 243.

Bug was introduced by https://github.com/cloudfoundry-incubator/service-fabrik-broker/commit/eb5a2824a39facf7994db3449b50b218f082cfc4.

If you follow method validateSchemaForRequest - there are branches only for schema equal draft-04,-06 and "". So if schema defined as draft-07 and code comes to line 243 validate has undefined value

dlapanik avatar Jun 06 '22 13:06 dlapanik

Sorry. we dropped support for draft-07 in latest version of interoperator.

Previously we were using an outdated version of ajv library. The older version of ajv uses draft-06 and draft-04 to validate draft-07. So I feel if you use the draft06 schema then the validation should happen fine. You may try this if it is easy.

The latest ajv brought in dedicated support for draft-07. We wanted to upgrade the ajv but did not had enough capacity to test with draft-07.

Thanks a lot for catching this bug. We love to support draft-07 but not finding time to work on it.

BTW, We are also open to contributions.

anoopjb avatar Aug 11 '22 09:08 anoopjb