I think I've found a very weird interaction between tech.v3.dataset reading a csv with missing values in the first data row and malli.dev/start! being active that causes m/coerce (I think it is actually -fail ) to throw an java.lang.IndexOutOfBoundsException .
actually get the same error when I try to run humanize on the dataset:
(humanize (explain (decode x))
this can be solved using print/read string
(me/humanize (-> anomaly prn-str read-string))
I've tried using both explainer and data-explainer and it doesn't seem to change anything.using a simple csv that looks like this
one,two
,2
calling coerce without malli.dev active returns normal results:
(try
(m/coerce [:map [:beep :int]] (first
(ds/rows
(ds/->dataset "./development/src/example_manifest.csv" {:key-fn keyword})))
(mt/string-transformer))
(catch Exception e (println e)))
;#error {
; :cause :malli.core/coercion
; :data {:type :malli.core/coercion, :message :malli.core/coercion, :data {:value {:two 2}, :schema [:map [:beep :int]], :explain {:schema [:map [:beep :int]], :value {:two 2}, :errors ({:path [:beep], :in [:beep], :schema [:map [:beep :int]], :value nil, :type :malli.core/missing-key})}}}
; :via
; [{:type clojure.lang.ExceptionInfo
; :message :malli.core/coercion
; :data {:type :malli.core/coercion, :message :malli.core/coercion, :data {:value {:two 2}, :schema [:map [:beep :int]], :explain {:schema [:map [:beep :int]], :value {:two 2}, :errors ({:path [:beep], :in [:beep], :schema [:map [:beep :int]], :value nil, :type :malli.core/missing-key})}}}
; :at [malli.core$_exception invokeStatic core.cljc 157]}]
but if I turn on malli.dev and run coerce again I get the out of bound error:
; turn on dev mode
((requiring-resolve 'malli.dev/start!))
; #error {
; :cause Index 1 out of bounds for length 1
; :via
; [{:type java.lang.IndexOutOfBoundsException
; :message Index 1 out of bounds for length 1
; :at [jdk.internal.util.Preconditions outOfBounds Preconditions.java 100]}]this can be solved at the ds/rows level by using :nil-missing
; this can be solved on the ds end by using :nil-missing?
(try
(m/coerce [:map [:beep :int]] (first
(ds/rows
(ds/->dataset "./development/src/example_manifest.csv" {:key-fn keyword})
{:nil-missing? true}))
(mt/string-transformer))
(catch Exception e (println e)))
; back to ':cause :malli.core/coercion' with dev mode active