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

Handle null prototypes in failure messaging #263

Merged
merged 1 commit into from
Jun 5, 2021

Conversation

72636c
Copy link
Contributor

@72636c 72636c commented Jun 3, 2021

I missed this case in #227. It's possible to crash Runtype.validate here by passing in an object with a null prototype that fails validation and triggers message generation via typeOf.

TypeError: Cannot read property 'name' of undefined
    at Object.typeOf (/workdir/node_modules/runtypes/lib/util.js:29:37)
    at Function.TYPE_INCORRECT (/workdir/node_modules/runtypes/lib/util.js:49:83)
    at /workdir/node_modules/runtypes/lib/types/union.js:127:31
    at Object.A._innerValidate (/workdir/node_modules/runtypes/lib/runtype.js:14:16)
    at Object.A.validate (/workdir/node_modules/runtypes/lib/runtype.js:16:46)

I missed this case in runtypes#227. It's possible to crash `Runtype.validate`
here by passing in an object with a null prototype that _fails_
validation and triggers message generation via `typeOf`.
@coveralls
Copy link
Collaborator

Coverage Status

Coverage increased (+0.01%) to 99.083% when pulling b1165ce on 72636c:null-prototype-failure-message into de67961 on pelotom:master.

Copy link
Collaborator

@yuhr yuhr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks~

@yuhr yuhr merged commit 1c54c1b into runtypes:master Jun 5, 2021
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

Successfully merging this pull request may close these issues.

None yet

3 participants