Fork me on GitHub
#malli
<
2022-11-29
>
Akiz16:11:37

Hi, I use ‘Malli’ for ‘route data validation’. My problem is that when I validate a large structure and get an error, the output to Emacs and REPL is very slow (other IDEs don’t have this problem), I have to wait several minutes before I can work again (the error output has ~10000 lines). I was thinking of shortening the error somehow, but I have no clear idea how. Has somebody here solved a similar problem?

respatialized16:11:26

malli.error/humanize can reduce the error size, but I'm not sure if you've already tried that or if it will suffice for your problem.

Noah Bogart16:11:53

how are you performing the validation? could you do something like (assert (m/validate X Schema) (-> X (m/explain Schema) (me/humanize)))?

respatialized16:11:44

a more general purpose solution might be to defer your error logging to an async logging library like https://github.com/BrunoBonacci/mulog, which provides a ring buffer mechanism that you can hook into with custom transformation functions to output errors and logs that narrow down to the specific thing you're trying to investigate.

☝️ 1
Akiz16:11:02

I forgot to tell that humanization doesnt work for me.. for unknown reason, this is my coercion in reitit-hander. It would probably help a lot.

(r.coercion.malli/create (-> r.coercion.malli/default-options                                                                          (assoc :strip-extra-keys true)                                                                   (update :error-keys #(conj % :humanized))))

Akiz16:11:57

@UFTRLDZEW i use timbre currently, but i would like to solve that problem on malli / emacs level first.

ikitommi16:11:09

several minutes 🙀

Akiz16:11:24

Oh, the error is not related to reitit coercion. It is invalid return output value…

Akiz16:11:15

@U055NJ5CC Yeah, vscode got it in second.

ikitommi16:11:44

do you have the pretty printing turned on?

ikitommi16:11:17

the colored outputs can be slow, dunno if there is a bug in rendering, fipp is supposed to be fast.

ikitommi16:11:57

but, not an emacs user (anymore), so not sure what happends there, if calva is fast with the same case.

Akiz16:11:13

Did you switch to vscode? Yeah, i do, i will try to disable it, thanks. Is there some easy way for instrumented fns to produce only humanized errors?

Akiz17:11:53

• disabling pretty/reporter for instrumentation helped a lot.. closing other windows in emacs as well 😄.

Ben Sless16:11:23

Regarding providing protobuf schema from malli, what do you think about defining a data representation for the protobuf spec (even as an external dependency), then defining the transformation from malli to it? I hate protobuf but it could be useful There are also limitations to account for, like oneOf can't be repeated, which make me pull my hair out