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

After upgrade, strange error message shown #2275

Closed
tdukai opened this issue Jan 14, 2020 · 5 comments
Closed

After upgrade, strange error message shown #2275

tdukai opened this issue Jan 14, 2020 · 5 comments
Assignees
Labels
support Questions, discussions, and general support

Comments

@tdukai
Copy link

tdukai commented Jan 14, 2020

Support plan

  • which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise): Community
  • is this issue currently blocking your project? (yes/no): yes
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: 12.14
  • module version: 17.0.2
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): hapi 19.0.4
  • any other relevant information: upgraded to latest components

How can we help?

After upgrading to the latest hapi environment (all components) I receive the following error message, when I try to start the hapi server:

Error: Cannot set uncompiled validation rules without configuring a validator

at new module.exports (/home/tdukai/unicomp/node/session/node_modules/@hapi/hapi/node_modules/@hapi/hoek/lib/error.js:23:19)
at Object.module.exports [as assert] (/home/tdukai/unicomp/node/session/node_modules/@hapi/hapi/node_modules/@hapi/hoek/lib/assert.js:20:11)
at Object.exports.compile (/home/tdukai/unicomp/node/session/node_modules/@hapi/hapi/lib/validation.js:48:10)
at module.exports.internals.Route._setupValidation (/home/tdukai/unicomp/node/session/node_modules/@hapi/hapi/lib/route.js:197:43)
at new module.exports.internals.Route (/home/tdukai/unicomp/node/session/node_modules/@hapi/hapi/lib/route.js:122:14)
at internals.Server._addRoute (/home/tdukai/unicomp/node/session/node_modules/@hapi/hapi/lib/server.js:498:23)
at internals.Server.route (/home/tdukai/unicomp/node/session/node_modules/@hapi/hapi/lib/server.js:491:22)
at Object.register (/home/tdukai/unicomp/node/session/lib/index.js:199:16)
at async internals.Server.register (/home/tdukai/unicomp/node/session/node_modules/@hapi/hapi/lib/server.js:466:17)
at async init (/home/tdukai/unicomp/node/session/lib/local.js:112:5)

The validation is very simple in this application

'use strict';

const joi = require('@hapi/joi'); 
const schemas = {};
// Add module specific namespace
schemas.session = {};
// Login schema

schemas.id = joi.string().regex(/^[0-9a-fA-F]{24}$/, 'Mongodb ObjectId');

// Supported Language
schemas.language = joi.string().lowercase(); 

// Supported organizations
schemas.org = joi.string().optional();

// Client side flags
schemas.clientId = joi.string().required().description('Client Id');
schemas.debugFlag = joi.boolean().default(false).description('Debug flag');

schemas.session.login = {
	email: joi.string().email().required(),
	password: joi.string().required(),
	utcOffset: joi.number()
};

// Register schema
schemas.session.register = {
	firstname: joi.string().required(),
	lastname: joi.string().required(),
	language: schemas.language,
	email: joi.string().email().required(),
	password: joi.string().required(),
	org: schemas.org,
	confirm:  joi.string().required().valid(joi.ref('password')),
	id: schemas.id
};

// Recover
schemas.session.recover = {
	language: schemas.language,
	email: joi.string().email().required()
};

// Password
schemas.session.password = {
	id: schemas.id,
	language: schemas.language,
	password: joi.string().required(),
	confirm:  joi.string().required().valid(joi.ref('password'))
};

I simple not understand what kind of validation or "compiling" required? What is the meaning of the message? What am I missing here? I looked at the documentation, but I could not find, what I am doing suddenly wrong. This solution worked perfectly under 15.1.1 and Hapi 18.4.0

@tdukai tdukai added the support Questions, discussions, and general support label Jan 14, 2020
@Marsup
Copy link
Collaborator

Marsup commented Jan 14, 2020

Major versions in node are synonymous with breaking changes, have you read the changelogs of the modules you bumped? In this case it's related to hapi's validator feature.

@Marsup Marsup closed this as completed Jan 14, 2020
@Marsup Marsup self-assigned this Jan 14, 2020
@tdukai
Copy link
Author

tdukai commented Jan 14, 2020

I have read the change log. Where is the change you mentioned, because I can't find it, nor the related documentation!

17.0.2
#2269
Ensure keys term always has right constructor
17.0.1
#2268
Move flag back to proto
17.0.0
Release Notesadditional information
breaking changes
#2263
Update deps
#2262
17.0.0 Release Notes
#2261
Remove ValidationError.annotate() from browser build
#2260
object.regex()
#2254
Giving an array argument to any.valid returns incorrect error
#2243
Allow _ in alias, arg, flag, modifier, override, rule, and term names
#2242
Can you allow _ in rule names?
#2231
Change errors.wrapArrays to errors.wrap.array
#2219
Add the ability to extend all types in place
#2200
Move ip and uri logic to address
down arrowShow More
16.1.8
#2226
object.with and object.without throw error on $ prefixed keys
#2218
Maximum call stack size exceeded​​ error for dataUri validation
#2212
Joi.string().email() considers "a@a.com/asd" as valid email
#2208
fix: describe() on schema with default value null
#2207
describe() on schema with default value null results in "Cannot read property 'Symbol(literal)' of null"
#2205
Cannot require a minimal number of matching object properties with pattern
#2190
Joi.string().domain() treats an email address as a valid domain name
#2187
Giving an array argument to any.allow(...values) gives incorrect error
#2181
Joi.alternatives produces confusing message when used with nested object and { abortEarly: false }
#2176
joi.types() is missing func alias
#2173
[Request] Allow mixing patch version
down arrowHide Issues
16.1.7
#2168
Date fails to enforce format when value is a number string
16.1.6
#2167
Error.captureStackTrace can't be used in all browser builds
#2165
Cannot read property 'delete' of undefined
16.1.5
#2156
node.get is not a function when validating
#2147
Joi v16: TypeError issue with valid(Joi.ref(x)).error()
16.1.4
#2134
Joi.any().default().describe() throws validation errors
16.1.3
#2131
TypeError: false.byteLength is not a function
16.1.2
#2128
when() fails when combined with prefs()
16.1.1
#2119
Use ^version
16.1.0
#2118
array.items() fails to invalidate when custom item error is used
#2116
Support .when({ is, then }) without subject ref
16.0.1
#2113
Valid emails are considered invalid
#2111
Joi.only is not a function
16.0.0
Release Notesadditional information
breaking changes
#2103
Support errors in manifest
#2102
Always convert -0 to 0
#2101
Apply link.concat() on resolved schema
#2099
Add when() break
#2097
Number validation fails with "1E3"
#2096
Apply link whens on linked schema, not the link
#2093
Manifest type conflicts with key type
#2092
Support Joi.in() for object keys
#2091
"-0" throw number.unsafe
#2089
Joi.in()
#2088
Always perform deep equal on valid() and invalid()
#2087
Fix comparison of array values (literals and references)
#2086
Preference to change label to path edge instead of full path
#2085
Default assert() to include stack
#2084
Shared schemas in links
#2083
Add a browser build to the github repo and npm package
#2082
Fix error thrown in the browser build. Closes #2081
#2081
The browser build (produced by webpack) throws an error when loading
#2080
Named schema links
#2079
Support no in when()
#2078
Default is to Joi.invalid(null, false, 0, '').required()
#2077
Compile valid values into valid+override
#2076
Allow/disallow list override
#2075
Log when() partials
#2074
Compile function into Joi.custom()
#2073
When object.pattern() matches option is not an array(), apply to each item
#2072
Custom function error shortcut
#2068
schema.describe() does not work, when default value is assigned to array in schema
#2065
Change alternatives to be consistent with other spread arguments
#2064
Throw on invalid schema during validation
#2062
Support chained when()
#2061
Keep switch as single condition on when() and conditional()
#2060
object.assert() ref should be relative to parent, not self
#2059
Support multiple usage of same schema with id
#2056
Schema test coverage
#2054
Rename alternatives.when() to alternatives.conditional()
#2051
Support for combine schema: allOf, oneOf, anyOf
#2049
Compile literals into any type with exact literal
#2048
Replace marker with Symbol.for()
#2046
Cast multi values of into a single type with valid()
#2041
Exclude error stack trace by default
#2040
Replace boolean.insensitive() with sensitive() and not apply to allow()
#2039
Allow mapping flags to rule methods with a different name
#2038
Stop matching object patterns once a match is found
#2037
v16.0.0 Release Notes
#2036
{ result, error } changed to error undefined instead of null
#2035
Skip error rendering preference
#2034
Consolidate date format errors
#2033
msg() template function to access other messages
#2032
Support custom sync functions for rules
#2031
Remove object and array string coerce
#2030
string.isoDate() fails on allow() and convert:false
#2027
Support templates as object.assert() subject
#2026
Change object.assert error context and rule argument name
#2024
Remove binary and string encoding support from the browser
#2023
Rule arguments validation
#2022
Support reverse order coerce
#2019
Consolidate refs with args
#2018
Support joi schema in refs assert
#2016
Consolidate refs assert's message/code
#2015
Ensure all levels of coerce are only called on non-undefined values
#2014
Change all _methods used on schema to use definition
#2013
Expose all internal extend() options externally
#2012
Rename func to function
#2010
New extension API
#2009
Global defaults
#2007
Change Infinity errors from any.invalid to number.infinity
#2006
Change error code any.empty to string.empty
#2005
Merging of two empty() should allow '' if it was explicitly defined
#2002
Remove prefs schema validation
#2001
Remove joi.defaults()
#1999
Fix outdated use of Joi.func().ref()
#1998
Split validate() to sync and async versions
#1995
Replace strip flag with result flag
#1994
Joi.string().uri() accepts 'http:/' as valid URL
#1993
Root reference
#1987
Extension build() support
#1986
Improve schema description validation
#1985
Refactor root
#1983
Change any.notes() to any.note() and require separate arguments
#1982
Change any.tags() to any.tag() and require separate arguments
#1981
Change any.example() to append by default
#1980
Rename string.regex() to string.pattern()
#1979
Link to root (regardless of depth)
#1978
Change only() to flag instead of alias of valid()
#1977
Replace date multiple and timestamp flag with format
#1976
Rename object.allowUnknown error to object.unknown
#1975
Remove description for default() function
#1974
Deep clone all values returned in describe()
#1973
Behavior of .concat() with tests redefinition
#1972
Applying raw after successful validation
#1968
Repalce lazy with link
#1965
How to properly detect domains?
#1962
Don't require pre function to take 3 arguments
#1961
Lazy once ignored when using with when()
#1960
Fix object peer dependencies error path
#1959
Debug tools
#1958
Warnings
#1957
Feature: Marking options as deprecated
#1956
Extension messages override base

@Marsup
Copy link
Collaborator

Marsup commented Jan 14, 2020

Like I said, in hapi's. You should always read the major release notes when you bump. Likewise for joi's.

@Marsup
Copy link
Collaborator

Marsup commented Jan 14, 2020

Just to be clear, those are links:
image

I'm not sure it's so obvious from the design, will happily take feedback.

@tdukai
Copy link
Author

tdukai commented Jan 14, 2020

Then I was looking at the wrong place... in joi...
Thanks! :)

@hapijs hapijs deleted a comment from roymap Jan 19, 2020
@hapijs hapijs locked and limited conversation to collaborators Jan 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

2 participants