Fork me on GitHub
#duct
<
2020-07-15
>
erwinrooijakkers11:07:35

I have a following config:

erwinrooijakkers11:07:58

{:duct.profile/base
 {:update-organization
  {:organization-client #ig/ref :client}

  :fetch-organization
  {:organization-client #ig/ref :client}

  :client {}

erwinrooijakkers11:07:06

Where client is an instantation of a deftype:

(defmethod ig/init-key :client
  [_ opts]
  (log/info ::client {:opts opts})
  (->OrganizationClient))

erwinrooijakkers11:07:53

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

erwinrooijakkers11:07:17

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

Kevin11:07:10

Being cast to fn probably means that there is a non module key outside of the base config

🔥 3
teodorlu11:07:52

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 ...

Kevin15:07:54

Thanks for reminding me. I still need to implement a test for this PR https://github.com/duct-framework/core/pull/32

Kevin15:07:03

This PR addresses this exact issue 🙂

Kevin15:07:31

I'll see if I can whip something up tonight

💯 3
Kevin11:07:32

The error is occurring in the fold modules function. Which verifies that

erwinrooijakkers12:07:19

Oh okay so some keys should be outside the base config?

erwinrooijakkers12:07:25

Like the :client

Kevin12:07:49

Only module keys should be outside of the base config