I have a following config:
{:duct.profile/base
{:update-organization
{:organization-client #ig/ref :client}
:fetch-organization
{:organization-client #ig/ref :client}
:client {}
Where client
is an instantation of a deftype
:
(defmethod ig/init-key :client
[_ opts]
(log/info ::client {:opts opts})
(->OrganizationClient))
This throws the following error:
13:33:21.229 INFO :client {:opts {}}
Execution error (ClassCastException) at duct.core/fold-modules$fn (core.clj:153).
OrganizationClient cannot be cast to clojure.lang.IFn
Any idea why?
Stacktrace:
1. Unhandled java.lang.ClassCastException
OrganizationClient cannot be cast to clojure.lang.IFn
core.clj: 153 duct.core/fold-modules/fn
core.cljc: 280 integrant.core$fold$fn__857/invoke
ArraySeq.java: 116 clojure.lang.ArraySeq/reduce
core.clj: 6827 clojure.core/reduce
core.clj: 6810 clojure.core/reduce
core.cljc: 280 integrant.core$fold/invokeStatic
core.cljc: 272 integrant.core$fold/invoke
core.clj: 153 duct.core/fold-modules
core.clj: 147 duct.core/fold-modules
core.clj: 190 duct.core/build-config
core.clj: 181 duct.core/build-config
core.clj: 201 duct.core/prep-config
core.clj: 192 duct.core/prep-config
dev.clj: 31 dev/eval19069/fn
repl.clj: 16 integrant.repl/prep/fn
AFn.java: 154 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
Var.java: 308 clojure.lang.Var/alterRoot
core.clj: 5510 clojure.core/alter-var-root
core.clj: 5505 clojure.core/alter-var-root
RestFn.java: 425 clojure.lang.RestFn/invoke
repl.clj: 16 integrant.repl/prep
repl.clj: 14 integrant.repl/prep
repl.clj: 54 integrant.repl/go
repl.clj: 53 integrant.repl/go
REPL: 484 dev/eval26347
REPL: 484 dev/eval26347
Compiler.java: 7177 clojure.lang.Compiler/eval
Compiler.java: 7132 clojure.lang.Compiler/eval
core.clj: 3214 clojure.core/eval
core.clj: 3210 clojure.core/eval
interruptible_eval.clj: 82 nrepl.middleware.interruptible-eval/evaluate/fn/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 665 clojure.core/apply
core.clj: 1973 clojure.core/with-bindings*
core.clj: 1973 clojure.core/with-bindings*
RestFn.java: 425 clojure.lang.RestFn/invoke
interruptible_eval.clj: 82 nrepl.middleware.interruptible-eval/evaluate/fn
main.clj: 437 clojure.main/repl/read-eval-print/fn
main.clj: 437 clojure.main/repl/read-eval-print
main.clj: 458 clojure.main/repl/fn
main.clj: 458 clojure.main/repl
main.clj: 368 clojure.main/repl
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 665 clojure.core/apply
core.clj: 660 clojure.core/apply
regrow.clj: 20 refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 79 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 56 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 145 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
AFn.java: 22 clojure.lang.AFn/run
session.clj: 202 nrepl.middleware.session/session-exec/main-loop/fn
session.clj: 201 nrepl.middleware.session/session-exec/main-loop
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 748 java.lang.Thread/run
Being cast to fn probably means that there is a non module key outside of the base config
I came in to ask about just a duct.database.sql.Boundary cannot be cast to class clojure.lang.IFn
-- I had put keys outside of the base config. Thanks!
I guess config validation error messages might be happy to receive some love ...
Thanks for reminding me. I still need to implement a test for this PR https://github.com/duct-framework/core/pull/32
This PR addresses this exact issue 🙂
I'll see if I can whip something up tonight
The error is occurring in the fold modules function. Which verifies that
Oh okay so some keys should be outside the base config?
Like the :client
Oh inside
Only module keys should be outside of the base config