Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional AJV-formats crash app #2960

Closed
b-steel opened this issue Dec 30, 2022 · 5 comments
Closed

Additional AJV-formats crash app #2960

b-steel opened this issue Dec 30, 2022 · 5 comments

Comments

@b-steel
Copy link
Contributor

b-steel commented Dec 30, 2022

Following the Documentation for Additional Types and adding any of the 'additional' types (such as iso-date-time) to validators.ts, typescript complains that iso-date-time is not a valid option. Furthermore, using those types in a schema causes the app to crash.

Steps to reproduce

npx @feathersjs/cli@pre generate app accept all defaults
Edit validators.ts by adding 'iso-date-time' to the list of formats (have to add //@ts-ignore for ts-node to not complain)
Edit users.schema.ts to add an attribute createdAt: Type.String({ format: 'iso-date-time' })
Run yarn dev
App Crashes

Repro

Looking at @feathersjs/schema it specifies [email protected], which looking at that version, iso-date-time is not included in that version. It is however included in [email protected] which their (ajv-formats) readme references.

So as far as I can tell, the feathers documentation references some options for the release candidate ajv-formats package but that is not the package references in @feathersjs/schema's package.json.

If I'm missing some step that I should have done to make this work then I apologize

Expected behavior

Should be able to enable that additional options in validators.ts that are shown in the documentation

Actual behavior

The app crashes with the message
unknown format "iso-date-time" ignored in schema at path "#/properties/modules/items/properties/createdAt"

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working):

"dependencies": {
    "@feathersjs/adapter-commons": "^5.0.0-pre.34",
    "@feathersjs/authentication": "^5.0.0-pre.34",
    "@feathersjs/authentication-client": "^5.0.0-pre.34",
    "@feathersjs/authentication-local": "^5.0.0-pre.34",
    "@feathersjs/authentication-oauth": "^5.0.0-pre.34",
    "@feathersjs/configuration": "^5.0.0-pre.34",
    "@feathersjs/errors": "^5.0.0-pre.34",
    "@feathersjs/feathers": "^5.0.0-pre.34",
    "@feathersjs/knex": "^5.0.0-pre.34",
    "@feathersjs/koa": "^5.0.0-pre.34",
    "@feathersjs/schema": "^5.0.0-pre.34",
    "@feathersjs/socketio": "^5.0.0-pre.34",
    "@feathersjs/transport-commons": "^5.0.0-pre.34",
    "@feathersjs/typebox": "^5.0.0-pre.34",
    "knex": "^2.3.0",
    "pg": "^8.8.0",
    "winston": "^3.8.2"
  },

NodeJS version:
16.15.1
Operating System:
OSX 12.6.1
Browser Version:

React Native Version:

Module Loader:

@daffl
Copy link
Member

daffl commented Jan 5, 2023

It looks like these formats are only available in the ajv-formats pre-release and not in the officially published version which is used here. You can use this version by adding the prerelease to your project:

npm install [email protected] --save

And then changing

import { Ajv, addFormats } from '@feathersjs/schema'

To

import { Ajv } from '@feathersjs/schema'
import addFormats from 'ajv-formats'

@daffl daffl closed this as completed Jan 5, 2023
@b-steel
Copy link
Contributor Author

b-steel commented Jan 5, 2023

Thanks for the help

@victor-gabou
Copy link

UP (@daffl)

The ajv-formats package haven't been updated since more than 2 years, we still have to force ajv to 3.0.0-rc to prevent issues with iso-date-time

Shouldn't feathers update ajv package to prevent this issue on future users?
Is ajv still a thing and shouldn't be avoided?

Whats the news about it?

kind regards,

@daffl
Copy link
Member

daffl commented Oct 3, 2023

This is an issue with the ajv-formats package. ajv-validator/ajv-formats#75 has the discussion on what would be necessary to get the latest version published.

@victor-gabou
Copy link

Thanks a lot for the related issue!

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

No branches or pull requests

3 participants