Fork me on GitHub
#reitit
<
2021-09-09
>
JoaquinIglesias08:09:22

So, I have been reading and running through the debugger the code, and I have managed to pinpoint the issue to the function request-coercer and the Coercion protocol being called there on https://github.com/metosin/reitit/blob/master/modules/reitit-core/src/reitit/coercion.cljc. On first sight, I am not so sure what the Coercion is doing. I will keep banging at it, but if anyone can provide any pointers, they would be very much appreciated. I actually started looking at spec-tools rather than reitit, because in my ignorance thought that was a likely location for the issue, and the code seemed simpler to wrap my head around. Under limited testing, that seemed to behave as expected under issue 494 conditions.

Tyler Nisonoff16:09:18

Not sure if you’re looking for a workaround for issue 494, but I’ve found wrapping the specs in st/spec (where st is spec-tools) allows the coercion to happen. For example:

(s/def ::or-example (st/spec (s/or
                               :one (st/spec string?)
                               :two (st/spec int))))

JoaquinIglesias08:09:03

I am definitely looking for a workaround. Thanks for the info Tyler!

JoaquinIglesias08:09:29

Oh, ok, I tried that one, and its well documented. But I did not understand that you need to wrap in st/spec the inner specs also! Thank you very much for clarifying that.

JoaquinIglesias11:09:17

Well, turns out I was wrong. Coercion calls spec-tools, and for the failing case in the issue's example, that call returns an empty map