fulcrologic / guardrails

Efficient, hassle-free function call validation with a concise inline syntax for clojure.spec and Malli
Eclipse Public License 2.0
236 stars 25 forks source link

guardrails is not compatible with Malli 0.14.0 #36

Closed FieryCod closed 7 months ago

FieryCod commented 7 months ago

It seems Malli has changed the arity of some internal function in Malli 0.14.0:

BUG: Internal error in Malli.

Wrong number of args (4) passed to: malli.dev.virhe/eval22220/fn--22221
at clojure.lang.AFn.throwArity (AFn.java:429)
    clojure.lang.AFn.invoke (AFn.java:44)
    clojure.lang.MultiFn.invoke (MultiFn.java:243)
    com.fulcrologic.guardrails.malli.core$_exception_doc.invokeStatic (core.cljc:99)
    com.fulcrologic.guardrails.malli.core$_exception_doc.invoke (core.cljc:97)
    com.fulcrologic.guardrails.malli.core$reporter$fn__23490.invoke (core.cljc:107)
    malli.dev.pretty$prettifier$fn__23448.doInvoke (pretty.cljc:173)
    clojure.lang.RestFn.invoke (RestFn.java:397)
    com.fulcrologic.guardrails.malli.core$humanize_schema$fn__23509.invoke (core.cljc:135)
    com.fulcrologic.guardrails.malli.core$humanize_schema.invokeStatic (core.cljc:134)
    com.fulcrologic.guardrails.malli.core$humanize_schema.invoke (core.cljc:124)
    com.fulcrologic.guardrails.core$run_check$fn__20550.invoke (core.cljc:132)
    com.fulcrologic.guardrails.core$run_check.invokeStatic (core.cljc:128)
    com.fulcrologic.guardrails.core$run_check.invoke (core.cljc:110)
gnl commented 7 months ago

Can you provide a bit more context on how to reproduce this? We tested extensively with 0.14.0, but there were some last-minute pretty-printing changes and this is quite likely related to that, given that it seems to involve virhe.

FieryCod commented 7 months ago

@gnl let me please know if you can reproduce using the following snippets:

src/main/main.clj

(ns main
  (:require
   [com.fulcrologic.guardrails.malli.core :refer [>defn]]))

(>defn hello
  [x]
  [:string => :int]
  :s)

(hello 30)

guardrails.edn

{:defn-macro             nil
 :async?                 true
 :guardrails/mcps        150
 :expound                {:show-valid-values? true
                                  :print-specs?       true}
 :guardrails/stack-trace :none ; or :full or :none
 :guardrails/use-stderr? true
 :guardrails/compact?    true
 :guardrails/trace?      true
 :throw?                 false
 :tap>?                  false}

deps.edn

{:deps {}
 :aliases {:dev {:jvm-opts ["-Dguardrails.enabled"]
                 :deps {metosin/malli {:mvn/version "0.14.0"}
                        com.fulcrologic/guardrails {:mvn/version "1.2.0-2"}}}
           :test {:extra-paths ["test"]
                  :deps {com.clojure-goes-fast/clj-java-decompiler {:mvn/version "0.3.4"}
                         criterium/criterium {:mvn/version "0.4.6"}}}}
 :paths ["src/main"]}
gnl commented 7 months ago

I see that you have malli 0.13.0 in your deps.edn – is it possible that there's been a mix-up and the problem occurs with 0.13.0 but not 0.14.0? There were breaking changes in 0.14.0 in the pretty-printing APIs, it's possible that Guardrails' custom pretty-printing is not backwards compatible.

FieryCod commented 7 months ago

I tweaked my project to use 0.13.0 to avoid above mentioned error and forgotten to change it to 0.14.0 in repro.

Corrected the repro case.

awkay commented 7 months ago

I assume that with :guardrails/compact? set to false it works fine?

awkay commented 7 months ago

Fixed in 1.2.1