This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-26
Channels
- # 100-days-of-code (3)
- # announcements (2)
- # beginners (237)
- # bitcoin (2)
- # boot (5)
- # cider (15)
- # cljs-dev (9)
- # cljsrn (6)
- # clojure (75)
- # clojure-estonia (1)
- # clojure-italy (8)
- # clojure-losangeles (1)
- # clojure-nl (1)
- # clojure-spec (68)
- # clojure-uk (80)
- # clojurescript (89)
- # cursive (31)
- # datomic (22)
- # emacs (2)
- # events (3)
- # figwheel-main (184)
- # fulcro (28)
- # graphql (1)
- # hyperfiddle (2)
- # jobs (1)
- # jobs-discuss (64)
- # luminus (5)
- # off-topic (16)
- # om (2)
- # onyx (1)
- # pedestal (12)
- # portkey (1)
- # re-frame (13)
- # reagent (56)
- # reitit (13)
- # ring-swagger (13)
- # shadow-cljs (145)
- # slack-help (2)
- # specter (6)
I added this issue comment earlier https://github.com/metosin/reitit/issues/145#issuecomment-424610485 but I’m starting to suspect it deserves its own issue. Unfortunately I have no idea how to reproduce…
tl;dr there’s something weird happening with data-specs. Reading the code, I have no idea how a reitit :parameters
definition can turn into a spec for which (ifn? spec)
is false.
It’s still pretty probable I’ve just misunderstood something and this is my fault 🙂
@hannu.hartikainen parameters are turned to specs via IntoSpec
protocol: https://github.com/metosin/reitit/blob/master/modules/reitit-spec/src/reitit/coercion/spec.cljc
I tried changing to normal specs (instead of data specs) and still get the same error. And it still works on my machine. Hmm.
I think you basically get Can't invoke spec with a non-function predicate
when you call the output of (ds/spec my-map)
directly.
Still can’t figure out how a different build environment could cause that to happen.
@hannu.hartikainen you shoudn’t call the spec directly, but to use it like a spec instead:
(require '[spec-tools.data-spec :as ds])
(require '[spec-tools.core :as st])
(def spec (ds/spec ::kikka {:x int?}))
(spec {:x 1})
; CompilerException clojure.lang.ExceptionInfo: Can't invoke spec with a non-function predicate
(st/decode spec {:x 1})
; {:x 1}
(st/decode spec {:x "1"})
; :clojure.spec.alpha/invalid
(st/decode spec {:x "1"} st/string-transformer)
; {:x 1}
for predicates, it can be invoked directly, so (st/spec int?)
can be used like int?
, but that’s kinda bonus, not an intented way. wondering if the invoking should be removed to avoid confusion…
My code doesn't invoke specs though. I just use the reitit coercion middleware, and that somehow causes a spec record to be invoked.
@hannu.hartikainen could you provide a small failing sample Repo?
I'll come back to you if I find a way to do that. As I said, the uberjar works just fine except when built on our Jenkins server...
Basically if I don't get any ideas about what might be the issue, I won't have time to do it. The build+deploy cycle is slow enough that I've been already trying to find any workaround to avoid investigating this further (current idea: just don't use coercion middleware when built in CI).