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

Coercion matcher sees :schema-generators.complete/missing #9

Open
gfredericks opened this issue May 8, 2017 · 2 comments
Open

Coercion matcher sees :schema-generators.complete/missing #9

gfredericks opened this issue May 8, 2017 · 2 comments

Comments

@gfredericks
Copy link
Contributor

I've isolated some strange behavior that I suspect is a bug, or else I'm misunderstanding how the coercion matchers are supposed to be used.

The following test (that I wrote to explain this) fails:

(deftest stringificator-test
  (is (not= ":schema-generators.complete/missing"
            (:foo
             (complete/complete
              {}
              {:foo s/Str}
              {s/Str str})))))

The coercion matcher function (str in this case) is being passed the keyword :schema-generators.complete/missing, which I think is the bug.

It looks like the main reason this doesn't have more pervasive effects is that the default coercion matchers in the schema library will throw exceptions in various ways when passed a keyword, and are wrapped in exception handling that suppresses those exceptions.

@w01fe
Copy link
Member

w01fe commented May 9, 2017

Thanks for the report. Yeah, it looks like we should check for ::missing first and directly fall through to the completion rather than calling the coercion first in that case. Does that seem like the right behavior to you? (PR welcome!)

@gfredericks
Copy link
Contributor Author

I haven't analyzed the code yet, but that certainly sounds plausible.

I'll look at it soon and make a PR if that fix is straightforward.

Thanks!

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

2 participants