Skip to content

Nullable field or schema not validating for None #251

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

Open
diogobaeder opened this issue Jun 4, 2020 · 12 comments
Open

Nullable field or schema not validating for None #251

diogobaeder opened this issue Jun 4, 2020 · 12 comments

Comments

@diogobaeder
Copy link

Hi,

I've just upgrade openapi-core on my project to 0.13.3, after some months without upgrading, and now nullable schemas are not validating None values anymore.

I found a commit which seems to fix the issue: 7307794 - but this seems to have been fixed after the latest tag.

Can you release a new patch version, with the most recent fixes, please? I use nullable schemas quite a lot, and need that fix...

Thanks!

@diogobaeder
Copy link
Author

Actually, just since I already created this ticket, there's a very similar issue still going on in the latest version from master: nullable arrays don't work, if I pass None it just fails instead of accepting the value. The reason is, the ArrayUnmarshaller tries to list(map(self.items_unmarshaller, value)) when the value is None, hence raising a NoneType error.

@stojan-jovic
Copy link

Reproducing the same issue.

Unfortunately, this project going to be dead soon (I would say), it seems that author has no time at all, which is fully understandable, but if there is no release for longer time for some already fixed issues, not sure is it worth to contribute here at all (I usually fix issue locally, but that's not it).

If I got time, I will try to create PR for this.

@diogobaeder
Copy link
Author

I wouldn't say the project is "going to be dead soon"; It's just that the author, @p1c2u , hasn't been much active on it, but recently I got some replies on tickets here. Maybe it's worth considering adding more people as direct collaborators of the project.

@stojan-jovic
Copy link

Maybe it's worth considering adding more people as direct collaborators of the project.

That's the key! Without that, there is no too much sense in providing fixes without possibility to release, even potential smaller issues are better than issue with paths resolving. In any case, when (i.e. if) that happens, I'm here to help with PRs.

@matt2000
Copy link

Looks like a new tag was cut in July, so this issue is moot? 0aeb144

@stojan-jovic
Copy link

I do not think that fix for this issue is included in the last release, but you can check.

@stojan-jovic
Copy link

stojan-jovic commented Dec 1, 2020

To correct myself (from previous comment) - handling nullable is partially fixed in the latest release (0.13.4), but still having two issues:

  • When nullable is set for arrays (i.e. type: array & nullable: true), null value not being properly validated, instead, it raising error: 'NoneType' object is not iterable. So, the same issue that diogobaeder reported in the second post.
  • When nullable is set for date-time (i.e. type: string, format: date-time & nullable: true), null value sometimes not being properly validated, instead, it raising error: Parser must be a string or character stream, not NoneType. So, validating null value for date-times working fine in some cases, but not in others (when it raising mentioned error). Still not sure what is the root cause of such behavior (if I figure out, will report that here).

@jgod
Copy link
Contributor

jgod commented Jan 13, 2021

@stojan-jovic I address the first case in #276.

What do we think ?

@srgkm
Copy link

srgkm commented Feb 1, 2021

any news on this issue?

@fajfer
Copy link

fajfer commented Jan 20, 2022

This is still an issue:
"message": "None for not nullable"

@diogobaeder
Copy link
Author

Still an issue. I just updated openapi-core in my project and all of a sudden I started getting that error for a schema model that is nullable. This is the schema, with the description simplified:

{'description': 'something something.',
     'format': 'uuid',
     'nullable': True,
     'type': 'string'}

This leads me to:

None is not of type 'string'

@diogobaeder
Copy link
Author

Almost same error for:

    {'additionalProperties': True,
     'description': 'something something.',
     'nullable': True,
     'type': 'object'}

and almost the same for:

{'format': 'date-time', 'nullable': True, 'type': 'string'}

I see this as a pretty big issue on the current version.

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

6 participants