Fork me on GitHub

I have a following config:


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

  {: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})


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



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
     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
          154  clojure.lang.AFn/applyToHelper
          144  clojure.lang.AFn/applyTo
          308  clojure.lang.Var/alterRoot
                  core.clj: 5510  clojure.core/alter-var-root
                  core.clj: 5505  clojure.core/alter-var-root
       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
    7177  clojure.lang.Compiler/eval
    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
          152  clojure.lang.AFn/applyToHelper
          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*
       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
       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
      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
           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
           22  clojure.lang.AFn/run
       748  java.lang.Thread/run


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

🔥 3

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


This PR addresses this exact issue 🙂


I'll see if I can whip something up tonight

💯 3

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


Only module keys should be outside of the base config